From: Andrew Bartlett Date: Wed, 29 Jun 2016 22:46:37 +0000 (-0700) Subject: lib: talloc: Call talloc_chunk_from_ptr() less often in __talloc_with_prefix() X-Git-Tag: tdb-1.3.10~569 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94a72849fa5be82c785f71ab58b8e813c94c51cd;p=thirdparty%2Fsamba.git lib: talloc: Call talloc_chunk_from_ptr() less often in __talloc_with_prefix() Rename 'ptc' pointer to parent as it's re-used as that name later in the function. Signed-off-by: Andrew Bartlett Reviewed-by: Jeremy Allison --- diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 26ceceed6cc..007b7a42ddb 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -637,6 +637,7 @@ static inline void *__talloc_with_prefix(const void *context, struct talloc_chunk *tc = NULL; struct talloc_memlimit *limit = NULL; size_t total_len = TC_HDR_SIZE + size + prefix_len; + struct talloc_chunk *parent = NULL; if (unlikely(context == NULL)) { context = null_context; @@ -650,14 +651,14 @@ static inline void *__talloc_with_prefix(const void *context, return NULL; } - if (context != NULL) { - struct talloc_chunk *ptc = talloc_chunk_from_ptr(context); + if (likely(context != NULL)) { + parent = talloc_chunk_from_ptr(context); - if (ptc->limit != NULL) { - limit = ptc->limit; + if (parent->limit != NULL) { + limit = parent->limit; } - tc = tc_alloc_pool(ptc, TC_HDR_SIZE+size, prefix_len); + tc = tc_alloc_pool(parent, TC_HDR_SIZE+size, prefix_len); } if (tc == NULL) { @@ -689,9 +690,7 @@ static inline void *__talloc_with_prefix(const void *context, tc->name = NULL; tc->refs = NULL; - if (likely(context)) { - struct talloc_chunk *parent = talloc_chunk_from_ptr(context); - + if (likely(context != NULL)) { if (parent->child) { parent->child->parent = NULL; tc->next = parent->child;