summaryrefslogtreecommitdiff
path: root/talloc_guide.txt
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-11-05 12:20:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:31 -0500
commit438a54b8b4df147405bba0b3b55a895d81a27b8a (patch)
tree4b929a469a56952371da37ce5a82afe024ebaebd /talloc_guide.txt
parent8a5c9c28410ae0320356fe1686ad0ee7d1ec0e7b (diff)
downloadsamba-438a54b8b4df147405bba0b3b55a895d81a27b8a.tar.gz
samba-438a54b8b4df147405bba0b3b55a895d81a27b8a.tar.bz2
samba-438a54b8b4df147405bba0b3b55a895d81a27b8a.zip
r3553: Allow talloc_reference to take a NULL pointer for the "ptr" argument.
This allows potentially NULL pointers to be referenced, without an if () for every use. (previously, it would segfault). Update doco, and allow talloc_unlink to match. Andrew Bartlett (This used to be commit 59757c7f9d0e08e3acacfb3116f6205057d5b119)
Diffstat (limited to 'talloc_guide.txt')
-rw-r--r--talloc_guide.txt5
1 files changed, 4 insertions, 1 deletions
diff --git a/talloc_guide.txt b/talloc_guide.txt
index a794cdffbe..b3b148d476 100644
--- a/talloc_guide.txt
+++ b/talloc_guide.txt
@@ -122,6 +122,8 @@ The return value of talloc_reference() is always the original pointer
which case it will return NULL (each additional reference consumes
around 48 bytes of memory on intel x86 platforms).
+If "ptr" is NULL, then the function is a no-op, and simply returns NULL.
+
After creating a reference you can free it in one of the following
ways:
@@ -144,7 +146,8 @@ context passed must either be a context used in talloc_reference()
with this pointer, or must be a direct parent of ptr.
Note that if the parent has already been removed using talloc_free()
-then this function will fail and will return -1.
+then this function will fail and will return -1. Likewise, if "ptr"
+is NULL, then the function will make no modifications and return -1.
Usually you can just use talloc_free() instead of talloc_unlink(), but
sometimes it is useful to have the additional control on which parent