summaryrefslogtreecommitdiff
path: root/main/stringfields.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/stringfields.c')
-rw-r--r--main/stringfields.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/main/stringfields.c b/main/stringfields.c
index 7e52bbc9e..30aa8cddd 100644
--- a/main/stringfields.c
+++ b/main/stringfields.c
@@ -55,12 +55,6 @@ static size_t optimal_alloc_size(size_t size)
return (1 << count) - ALLOCATOR_OVERHEAD;
}
-static void *calloc_wrapper(unsigned int num_structs, size_t struct_size,
- const char *file, int lineno, const char *func)
-{
- return __ast_calloc(num_structs, struct_size, file, lineno, func);
-}
-
/*! \brief add a new block to the pool.
* We can only allocate from the topmost pool, so the
* fields in *mgr reflect the size of that only.
@@ -71,7 +65,8 @@ static int add_string_pool(struct ast_string_field_mgr *mgr, struct ast_string_f
struct ast_string_field_pool *pool;
size_t alloc_size = optimal_alloc_size(sizeof(*pool) + size);
- if (!(pool = calloc_wrapper(1, alloc_size, file, lineno, func))) {
+ pool = __ast_calloc(1, alloc_size, file, lineno, func);
+ if (!pool) {
return -1;
}
@@ -184,11 +179,11 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_
}
mgr->last_alloc = NULL;
-#if defined(__AST_DEBUG_MALLOC)
+ /* v-- MALLOC_DEBUG information */
mgr->owner_file = file;
mgr->owner_func = func;
mgr->owner_line = lineno;
-#endif
+ /* ^-- MALLOC_DEBUG information */
if (AST_VECTOR_INIT(&mgr->string_fields, initial_vector_size)) {
return -1;
@@ -227,13 +222,10 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr
new_size *= 2;
}
-#if defined(__AST_DEBUG_MALLOC)
- if (add_string_pool(mgr, pool_head, new_size, mgr->owner_file, mgr->owner_line, mgr->owner_func))
- return NULL;
-#else
- if (add_string_pool(mgr, pool_head, new_size, __FILE__, __LINE__, __FUNCTION__))
+ if (add_string_pool(mgr, pool_head, new_size,
+ mgr->owner_file, mgr->owner_line, mgr->owner_func)) {
return NULL;
-#endif
+ }
}
/* pool->base is always aligned (gcc aligned attribute). We ensure that
@@ -388,8 +380,8 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
}
void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_size,
- size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file,
- int lineno, const char *func)
+ size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size,
+ const char *file, int lineno, const char *func)
{
struct ast_string_field_mgr *mgr;
struct ast_string_field_pool *pool;
@@ -402,7 +394,8 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz
ast_assert(num_structs == 1);
- if (!(allocation = calloc_wrapper(num_structs, size_to_alloc, file, lineno, func))) {
+ allocation = __ast_calloc(num_structs, size_to_alloc, file, lineno, func);
+ if (!allocation) {
return NULL;
}
@@ -426,11 +419,11 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz
mgr->embedded_pool = pool;
*pool_head = pool;
pool->size = size_to_alloc - struct_size - sizeof(*pool);
-#if defined(__AST_DEBUG_MALLOC)
- mgr->owner_file = file;
- mgr->owner_func = func;
- mgr->owner_line = lineno;
-#endif
+ /* v-- MALLOC_DEBUG information */
+ mgr->owner_file = file;
+ mgr->owner_func = func;
+ mgr->owner_line = lineno;
+ /* ^-- MALLOC_DEBUG information */
return allocation;
}