diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-09-13 00:05:07 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:18:29 -0500 |
commit | 1a5978445199a1d8697a5604761899aa065059fe (patch) | |
tree | 7d6dd6ac85243bc6b20d8bed7455f1d02a54cbf6 /source4/lib/talloc/talloc.3.xml | |
parent | d21cb7e2d29a8c496bb139b5f8086949305e76a2 (diff) | |
download | samba-1a5978445199a1d8697a5604761899aa065059fe.tar.gz samba-1a5978445199a1d8697a5604761899aa065059fe.tar.bz2 samba-1a5978445199a1d8697a5604761899aa065059fe.zip |
r18435: added a function talloc_move() which is like talloc_steal(), but is
meant for moving pointers between structures. The difference is that
talloc_move() will zero the source pointer, thus ensuring you don't
reference the pointer in the old context.
talloc_move() is appropriate in some, but not all cases where we use
talloc_steal() now. The interface came out of a discussion with
Jeremy.
(This used to be commit 200756017e1867faa207703eddc00a75ae4527df)
Diffstat (limited to 'source4/lib/talloc/talloc.3.xml')
-rw-r--r-- | source4/lib/talloc/talloc.3.xml | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source4/lib/talloc/talloc.3.xml b/source4/lib/talloc/talloc.3.xml index a448e8d978..76b54ddb80 100644 --- a/source4/lib/talloc/talloc.3.xml +++ b/source4/lib/talloc/talloc.3.xml @@ -369,7 +369,7 @@ talloc_realloc(ctx, ptr, type, 0) ==> talloc_free(ptr);</programlisting> known so the type-safe talloc_realloc() cannot be used. </para> </refsect2> - <refsect2><title>void *talloc_steal(const void *<emphasis role="italic">new_ctx</emphasis>, const void *<emphasis role="italic">ptr</emphasis>);</title> + <refsect2><title>TYPE *talloc_steal(const void *<emphasis role="italic">new_ctx</emphasis>, const TYPE *<emphasis role="italic">ptr</emphasis>);</title> <para> The talloc_steal() function changes the parent context of a talloc pointer. It is typically used when the context that the @@ -387,6 +387,16 @@ talloc_realloc(ctx, ptr, type, 0) ==> talloc_free(ptr);</programlisting> data if you do this. </para> </refsect2> + <refsect2><title>TYPE *talloc_move(const void *<emphasis role="italic">new_ctx</emphasis>, TYPE *<emphasis role="italic">ptr</emphasis>);</title> + <para> + The talloc_move() function is a wrapper around + talloc_steal() which zeros the source pointer after the + move. This avoids a potential source of bugs where a + programmer leaves a pointer in two structures, and uses the + pointer from the old structure after it has been moved to a + new one. + </para> + </refsect2> <refsect2><title>size_t talloc_total_size(const void *<emphasis role="italic">ptr</emphasis>);</title> <para> The talloc_total_size() function returns the total size in bytes |