summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-07-02 22:17:58 +0000
committerJeremy Allison <jra@samba.org>2001-07-02 22:17:58 +0000
commitd6d9375efd9baf3eefc8550e5f4b964914597511 (patch)
tree7554788c76345272730f3ce7d6df40ae93ca31fd /source3/lib
parent6780f050e1d909cdfcdeeb7be32fa5beed3bd437 (diff)
downloadsamba-d6d9375efd9baf3eefc8550e5f4b964914597511.tar.gz
samba-d6d9375efd9baf3eefc8550e5f4b964914597511.tar.bz2
samba-d6d9375efd9baf3eefc8550e5f4b964914597511.zip
Made talloc_realloc() semantics match realloc(). JF was complaining :-).
realloc(NULL) == malloc. realloc(p,0) == free() - a no-op in talloc. Jeremy. (This used to be commit 1ab31e5db53bc839d2785cce4d3c739c8004bbf6)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/talloc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index e83369f379..a8ee481744 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -80,6 +80,14 @@ void *talloc_realloc(TALLOC_CTX *t, void *ptr, size_t size)
{
struct talloc_chunk *tc;
+ /* size zero is equivalent to free() */
+ if (size == 0)
+ return NULL;
+
+ /* realloc(NULL) is equavalent to malloc() */
+ if (ptr == NULL)
+ return talloc(t, size);
+
for (tc=t->list; tc; tc=tc->next) {
if (tc->ptr == ptr) {
ptr = realloc(ptr, size);