summaryrefslogtreecommitdiff
path: root/source4/lib/talloc/talloc.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-13 00:05:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:29 -0500
commit1a5978445199a1d8697a5604761899aa065059fe (patch)
tree7d6dd6ac85243bc6b20d8bed7455f1d02a54cbf6 /source4/lib/talloc/talloc.c
parentd21cb7e2d29a8c496bb139b5f8086949305e76a2 (diff)
downloadsamba-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.c')
-rw-r--r--source4/lib/talloc/talloc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index d2f7a5d828..2b80594e80 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -738,6 +738,17 @@ void *_talloc_steal(const void *new_ctx, const void *ptr)
}
/*
+ a wrapper around talloc_steal() for situations where you are moving a pointer
+ between two structures, and want the old pointer to be set to NULL
+*/
+void *_talloc_move(const void *new_ctx, const void **pptr)
+{
+ void *ret = _talloc_steal(new_ctx, *pptr);
+ (*pptr) = NULL;
+ return ret;
+}
+
+/*
return the total size of a talloc pool (subtree)
*/
size_t talloc_total_size(const void *ptr)