summaryrefslogtreecommitdiff
path: root/source4/lib/talloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/talloc.c')
-rw-r--r--source4/lib/talloc.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c
index fc65546063..5c1f3e7dcd 100644
--- a/source4/lib/talloc.c
+++ b/source4/lib/talloc.c
@@ -273,6 +273,10 @@ int talloc_unlink(const void *context, void *ptr)
struct talloc_chunk *tc_p, *new_p;
void *new_parent;
+ if (context == NULL) {
+ context = null_context;
+ }
+
if (talloc_unreference(context, ptr) == 0) {
return 0;
}
@@ -561,6 +565,10 @@ void *talloc_steal(const void *new_ctx, const void *ptr)
return NULL;
}
+ if (new_ctx == NULL) {
+ new_ctx = null_context;
+ }
+
tc = talloc_chunk_from_ptr(ptr);
if (new_ctx == NULL) {
@@ -948,16 +956,11 @@ void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned
}
/*
- a alloc function for ldb that uses talloc
+ a function version of talloc_realloc(), so it can be passed as a function pointer
+ to libraries that want a realloc function (a realloc function encapsulates
+ all the basic capabilities of an allocation library, which is why this is useful)
*/
-void *talloc_ldb_alloc(void *context, void *ptr, size_t size)
+void *talloc_realloc_fn(const void *context, void *ptr, size_t size)
{
- if (ptr == NULL) {
- return talloc(context, size);
- }
- if (size == 0) {
- talloc_free(ptr);
- return NULL;
- }
- return talloc_realloc(context, ptr, size);
+ return _talloc_realloc(context, ptr, size, NULL);
}