From d2a5927bd77a94256f7d8ee7098f66c4c0afd25d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 29 Jun 2016 16:41:52 -0700 Subject: [PATCH] lib: talloc: Rename the internals of _talloc_free_internal() to _tc_free_internal(). Make it use a struct talloc_chunk *tc parameter. Define _talloc_free_internal() in terms of _tc_free_internal(). Signed-off-by: Andrew Bartlett Reviewed-by: Jeremy Allison --- lib/talloc/talloc.c | 50 ++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 007b7a42ddb..428fb8aa7ad 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -999,29 +999,16 @@ static inline void _tc_free_children_internal(struct talloc_chunk *tc, void *ptr, const char *location); +static inline int _talloc_free_internal(void *ptr, const char *location); + /* - internal talloc_free call + internal free call that takes a struct talloc_chunk *. */ -static inline int _talloc_free_internal(void *ptr, const char *location) +static inline int _tc_free_internal(struct talloc_chunk *tc, + const char *location) { - struct talloc_chunk *tc; void *ptr_to_free; - - if (unlikely(ptr == NULL)) { - return -1; - } - - /* possibly initialised the talloc fill value */ - if (unlikely(!talloc_fill.initialised)) { - const char *fill = getenv(TALLOC_FILL_ENV); - if (fill != NULL) { - talloc_fill.enabled = true; - talloc_fill.fill_value = strtoul(fill, NULL, 0); - } - talloc_fill.initialised = true; - } - - tc = talloc_chunk_from_ptr(ptr); + void *ptr = TC_PTR_FROM_CHUNK(tc); if (unlikely(tc->refs)) { int is_child; @@ -1125,6 +1112,31 @@ static inline int _talloc_free_internal(void *ptr, const char *location) return 0; } +/* + internal talloc_free call +*/ +static inline int _talloc_free_internal(void *ptr, const char *location) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return -1; + } + + /* possibly initialised the talloc fill value */ + if (unlikely(!talloc_fill.initialised)) { + const char *fill = getenv(TALLOC_FILL_ENV); + if (fill != NULL) { + talloc_fill.enabled = true; + talloc_fill.fill_value = strtoul(fill, NULL, 0); + } + talloc_fill.initialised = true; + } + + tc = talloc_chunk_from_ptr(ptr); + return _tc_free_internal(tc, location); +} + static inline size_t _talloc_total_limit_size(const void *ptr, struct talloc_memlimit *old_limit, struct talloc_memlimit *new_limit); -- 2.47.3