lib: talloc: Change __talloc_with_prefix() to return a struct talloc_chunk *.
authorAndrew Bartlett <abartlet@samba.org>
Fri, 17 Jun 2016 23:58:34 +0000 (16:58 -0700)
committerJeremy Allison <jra@samba.org>
Sun, 3 Jul 2016 12:26:17 +0000 (14:26 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/talloc/talloc.c

index 7b9fc7a9240d667be8b544537733f8d7648db4f7..3873fa6bc1ffd717894c330adb827d265dc5c290 100644 (file)
@@ -625,8 +625,10 @@ static inline struct talloc_chunk *tc_alloc_pool(struct talloc_chunk *parent,
 /*
    Allocate a bit of memory as a child of an existing pointer
 */
-static inline void *__talloc_with_prefix(const void *context, size_t size,
-                                       size_t prefix_len)
+static inline void *__talloc_with_prefix(const void *context,
+                                       size_t size,
+                                       size_t prefix_len,
+                                       struct talloc_chunk **tc_ret)
 {
        struct talloc_chunk *tc = NULL;
        struct talloc_memlimit *limit = NULL;
@@ -700,12 +702,14 @@ static inline void *__talloc_with_prefix(const void *context, size_t size,
                tc->next = tc->prev = tc->parent = NULL;
        }
 
+       *tc_ret = tc;
        return TC_PTR_FROM_CHUNK(tc);
 }
 
 static inline void *__talloc(const void *context, size_t size)
 {
-       return __talloc_with_prefix(context, size, 0);
+       struct talloc_chunk *tc;
+       return __talloc_with_prefix(context, size, 0, &tc);
 }
 
 /*
@@ -718,13 +722,12 @@ static inline void *_talloc_pool(const void *context, size_t size)
        struct talloc_pool_hdr *pool_hdr;
        void *result;
 
-       result = __talloc_with_prefix(context, size, TP_HDR_SIZE);
+       result = __talloc_with_prefix(context, size, TP_HDR_SIZE, &tc);
 
        if (unlikely(result == NULL)) {
                return NULL;
        }
 
-       tc = talloc_chunk_from_ptr(result);
        pool_hdr = talloc_pool_from_chunk(tc);
 
        tc->flags |= TALLOC_FLAG_POOL;