Merge "Fix checks for allocation debugging."
This commit is contained in:
commit
c82cef8441
10 changed files with 47 additions and 47 deletions
|
@ -35,7 +35,7 @@ AST_LIST_HEAD_NOLOCK(varshead, ast_var_t);
|
||||||
|
|
||||||
struct varshead *ast_var_list_create(void);
|
struct varshead *ast_var_list_create(void);
|
||||||
void ast_var_list_destroy(struct varshead *head);
|
void ast_var_list_destroy(struct varshead *head);
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function);
|
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function);
|
||||||
#define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -907,7 +907,7 @@ void ast_category_destroy(struct ast_category *cat);
|
||||||
struct ast_variable *ast_category_detach_variables(struct ast_category *cat);
|
struct ast_variable *ast_category_detach_variables(struct ast_category *cat);
|
||||||
void ast_category_rename(struct ast_category *cat, const char *name);
|
void ast_category_rename(struct ast_category *cat, const char *name);
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno);
|
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno);
|
||||||
#define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
#define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -251,7 +251,7 @@ unsigned int ast_hashtab_hash_short(const short num);
|
||||||
* \param hash a func ptr to do the hashing
|
* \param hash a func ptr to do the hashing
|
||||||
* \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now
|
* \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab * _ast_hashtab_create(int initial_buckets,
|
struct ast_hashtab * _ast_hashtab_create(int initial_buckets,
|
||||||
int (*compare)(const void *a, const void *b),
|
int (*compare)(const void *a, const void *b),
|
||||||
int (*resize)(struct ast_hashtab *),
|
int (*resize)(struct ast_hashtab *),
|
||||||
|
@ -294,7 +294,7 @@ void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void *
|
||||||
* \retval 1 on success
|
* \retval 1 on success
|
||||||
* \retval 0 if there's a problem
|
* \retval 0 if there's a problem
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
|
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -311,7 +311,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj);
|
||||||
* \retval 1 on success
|
* \retval 1 on success
|
||||||
* \retval 0 if there's a problem
|
* \retval 0 if there's a problem
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func);
|
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -324,7 +324,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
|
||||||
* \retval 1 on success
|
* \retval 1 on success
|
||||||
* \retval 0 if there's a problem, or it's already there.
|
* \retval 0 if there's a problem, or it's already there.
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
|
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -362,7 +362,7 @@ int ast_hashtab_size( struct ast_hashtab *tab);
|
||||||
int ast_hashtab_capacity( struct ast_hashtab *tab);
|
int ast_hashtab_capacity( struct ast_hashtab *tab);
|
||||||
|
|
||||||
/*! \brief Return a copy of the hash table */
|
/*! \brief Return a copy of the hash table */
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func);
|
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -370,7 +370,7 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \brief Gives an iterator to hastable */
|
/*! \brief Gives an iterator to hastable */
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -395,7 +395,7 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj);
|
||||||
/* ------------------ */
|
/* ------------------ */
|
||||||
|
|
||||||
/*! \brief Gives an iterator to hastable */
|
/*! \brief Gives an iterator to hastable */
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -97,7 +97,7 @@ typedef int (*ast_heap_cmp_fn)(void *elm1, void *elm2);
|
||||||
* \return An instance of a max heap
|
* \return An instance of a max heap
|
||||||
* \since 1.6.1
|
* \since 1.6.1
|
||||||
*/
|
*/
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
|
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
|
||||||
ssize_t index_offset, const char *file, int lineno, const char *func);
|
ssize_t index_offset, const char *file, int lineno, const char *func);
|
||||||
#define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
|
@ -126,7 +126,7 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h);
|
||||||
* \retval non-zero failure
|
* \retval non-zero failure
|
||||||
* \since 1.6.1
|
* \since 1.6.1
|
||||||
*/
|
*/
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func);
|
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func);
|
||||||
#define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -616,7 +616,7 @@ int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str *
|
||||||
* \note The result of this function is dynamically allocated memory, and must
|
* \note The result of this function is dynamically allocated memory, and must
|
||||||
* be free()'d after it is no longer needed.
|
* be free()'d after it is no longer needed.
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
#define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
AST_INLINE_API(
|
AST_INLINE_API(
|
||||||
struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
|
struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
|
||||||
|
@ -771,7 +771,7 @@ char *ast_str_truncate(struct ast_str *buf, ssize_t len),
|
||||||
/*!
|
/*!
|
||||||
* Make space in a new string (e.g. to read in data from a file)
|
* Make space in a new string (e.g. to read in data from a file)
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
AST_INLINE_API(
|
AST_INLINE_API(
|
||||||
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function),
|
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function),
|
||||||
{
|
{
|
||||||
|
@ -964,7 +964,7 @@ enum {
|
||||||
* through calling one of the other functions or macros defined in this
|
* through calling one of the other functions or macros defined in this
|
||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
|
int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
|
||||||
int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func);
|
int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func);
|
||||||
#define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
#define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__)
|
||||||
|
|
|
@ -35,7 +35,7 @@ ASTERISK_REGISTER_FILE()
|
||||||
#include "asterisk/strings.h"
|
#include "asterisk/strings.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function)
|
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function)
|
||||||
#else
|
#else
|
||||||
struct ast_var_t *ast_var_assign(const char *name, const char *value)
|
struct ast_var_t *ast_var_assign(const char *name, const char *value)
|
||||||
|
@ -45,7 +45,7 @@ struct ast_var_t *ast_var_assign(const char *name, const char *value)
|
||||||
int name_len = strlen(name) + 1;
|
int name_len = strlen(name) + 1;
|
||||||
int value_len = strlen(value) + 1;
|
int value_len = strlen(value) + 1;
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
|
if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
|
||||||
#else
|
#else
|
||||||
if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
|
if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
|
||||||
|
|
|
@ -283,7 +283,7 @@ struct ast_config_include {
|
||||||
static void ast_variable_destroy(struct ast_variable *doomed);
|
static void ast_variable_destroy(struct ast_variable *doomed);
|
||||||
static void ast_includes_destroy(struct ast_config_include *incls);
|
static void ast_includes_destroy(struct ast_config_include *incls);
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno)
|
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno)
|
||||||
#else
|
#else
|
||||||
struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
|
struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
|
||||||
|
@ -300,7 +300,7 @@ struct ast_variable *ast_variable_new(const char *name, const char *value, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
(variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func))
|
(variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func))
|
||||||
#else
|
#else
|
||||||
(variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable)))
|
(variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable)))
|
||||||
|
|
|
@ -44,7 +44,7 @@ ASTERISK_REGISTER_FILE()
|
||||||
#include "asterisk/hashtab.h"
|
#include "asterisk/hashtab.h"
|
||||||
|
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
|
||||||
#define ast_hashtab_resize(a) _ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define ast_hashtab_resize(a) _ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
|
@ -219,7 +219,7 @@ unsigned int ast_hashtab_hash_short(const short x)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ast_hashtab *
|
struct ast_hashtab *
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
_ast_hashtab_create
|
_ast_hashtab_create
|
||||||
#else
|
#else
|
||||||
ast_hashtab_create
|
ast_hashtab_create
|
||||||
|
@ -230,14 +230,14 @@ ast_hashtab_create
|
||||||
int (*newsize)(struct ast_hashtab *tab),
|
int (*newsize)(struct ast_hashtab *tab),
|
||||||
unsigned int (*hash)(const void *obj),
|
unsigned int (*hash)(const void *obj),
|
||||||
int do_locking
|
int do_locking
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
, const char *file, int lineno, const char *function
|
, const char *file, int lineno, const char *function
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct ast_hashtab *ht;
|
struct ast_hashtab *ht;
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function)))
|
if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function)))
|
||||||
#else
|
#else
|
||||||
if (!(ht = ast_calloc(1, sizeof(*ht))))
|
if (!(ht = ast_calloc(1, sizeof(*ht))))
|
||||||
|
@ -247,7 +247,7 @@ ast_hashtab_create
|
||||||
while (!ast_is_prime(initial_buckets)) /* make sure this is prime */
|
while (!ast_is_prime(initial_buckets)) /* make sure this is prime */
|
||||||
initial_buckets++;
|
initial_buckets++;
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
if (!(ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), file, lineno, function))) {
|
if (!(ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), file, lineno, function))) {
|
||||||
#else
|
#else
|
||||||
if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) {
|
if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) {
|
||||||
|
@ -275,7 +275,7 @@ ast_hashtab_create
|
||||||
return ht;
|
return ht;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func)
|
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj))
|
struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj))
|
||||||
|
@ -288,7 +288,7 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(ht->array =
|
if (!(ht->array =
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), file, lineno, func)
|
__ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)))
|
ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)))
|
||||||
|
@ -316,7 +316,7 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun
|
||||||
while (b) {
|
while (b) {
|
||||||
void *newobj = (*obj_dup_func)(b->object);
|
void *newobj = (*obj_dup_func)(b->object);
|
||||||
if (newobj)
|
if (newobj)
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
_ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func);
|
_ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func);
|
||||||
#else
|
#else
|
||||||
ast_hashtab_insert_immediate_bucket(ht, newobj, i);
|
ast_hashtab_insert_immediate_bucket(ht, newobj, i);
|
||||||
|
@ -427,7 +427,7 @@ void ast_hashtab_destroy(struct ast_hashtab *tab, void (*objdestroyfunc)(void *o
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
|
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
|
int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
|
||||||
|
@ -444,7 +444,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
|
||||||
|
|
||||||
h = (*tab->hash)(obj) % tab->hash_tab_size;
|
h = (*tab->hash)(obj) % tab->hash_tab_size;
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
res = _ast_hashtab_insert_immediate_bucket(tab, obj, h, file, lineno, func);
|
res = _ast_hashtab_insert_immediate_bucket(tab, obj, h, file, lineno, func);
|
||||||
#else
|
#else
|
||||||
res = ast_hashtab_insert_immediate_bucket(tab, obj, h);
|
res = ast_hashtab_insert_immediate_bucket(tab, obj, h);
|
||||||
|
@ -456,7 +456,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func)
|
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h)
|
int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h)
|
||||||
|
@ -475,7 +475,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
|
||||||
tab->largest_bucket_size = c + 1;
|
tab->largest_bucket_size = c + 1;
|
||||||
|
|
||||||
if (!(b =
|
if (!(b =
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(1, sizeof(*b), file, lineno, func)
|
__ast_calloc(1, sizeof(*b), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(1, sizeof(*b))
|
ast_calloc(1, sizeof(*b))
|
||||||
|
@ -498,7 +498,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
|
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
|
int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
|
||||||
|
@ -514,7 +514,7 @@ int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
|
||||||
ast_rwlock_wrlock(&tab->lock);
|
ast_rwlock_wrlock(&tab->lock);
|
||||||
|
|
||||||
if (!ast_hashtab_lookup_bucket(tab, obj, &bucket)) {
|
if (!ast_hashtab_lookup_bucket(tab, obj, &bucket)) {
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int ret2 = _ast_hashtab_insert_immediate_bucket(tab, obj, bucket, file, lineno, func);
|
int ret2 = _ast_hashtab_insert_immediate_bucket(tab, obj, bucket, file, lineno, func);
|
||||||
#else
|
#else
|
||||||
int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket);
|
int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket);
|
||||||
|
@ -637,7 +637,7 @@ int ast_hashtab_capacity( struct ast_hashtab *tab)
|
||||||
/* the insert operation calls this, and is wrlock'd when it does. */
|
/* the insert operation calls this, and is wrlock'd when it does. */
|
||||||
/* if you want to call it, you should set the wrlock yourself */
|
/* if you want to call it, you should set the wrlock yourself */
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
static void ast_hashtab_resize(struct ast_hashtab *tab)
|
static void ast_hashtab_resize(struct ast_hashtab *tab)
|
||||||
|
@ -660,7 +660,7 @@ static void ast_hashtab_resize(struct ast_hashtab *tab)
|
||||||
}
|
}
|
||||||
free(tab->array);
|
free(tab->array);
|
||||||
if (!(tab->array =
|
if (!(tab->array =
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func)
|
__ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(newsize, sizeof(*(tab->array)))
|
ast_calloc(newsize, sizeof(*(tab->array)))
|
||||||
|
@ -691,7 +691,7 @@ static void ast_hashtab_resize(struct ast_hashtab *tab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
|
struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
|
||||||
|
@ -701,7 +701,7 @@ struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
|
||||||
struct ast_hashtab_iter *it;
|
struct ast_hashtab_iter *it;
|
||||||
|
|
||||||
if (!(it =
|
if (!(it =
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(1, sizeof(*it), file, lineno, func)
|
__ast_calloc(1, sizeof(*it), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(1, sizeof(*it))
|
ast_calloc(1, sizeof(*it))
|
||||||
|
@ -718,7 +718,7 @@ struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use this function to get a write lock */
|
/* use this function to get a write lock */
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab)
|
struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab)
|
||||||
|
@ -728,7 +728,7 @@ struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *t
|
||||||
struct ast_hashtab_iter *it;
|
struct ast_hashtab_iter *it;
|
||||||
|
|
||||||
if (!(it =
|
if (!(it =
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(1, sizeof(*it), file, lineno, func)
|
__ast_calloc(1, sizeof(*it), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(1, sizeof(*it))
|
ast_calloc(1, sizeof(*it))
|
||||||
|
|
14
main/heap.c
14
main/heap.c
|
@ -111,7 +111,7 @@ int ast_heap_verify(struct ast_heap *h)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
|
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
|
||||||
ssize_t index_offset, const char *file, int lineno, const char *func)
|
ssize_t index_offset, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
|
@ -131,7 +131,7 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(h =
|
if (!(h =
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(1, sizeof(*h), file, lineno, func)
|
__ast_calloc(1, sizeof(*h), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(1, sizeof(*h))
|
ast_calloc(1, sizeof(*h))
|
||||||
|
@ -145,7 +145,7 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f
|
||||||
h->avail_len = (1 << init_height) - 1;
|
h->avail_len = (1 << init_height) - 1;
|
||||||
|
|
||||||
if (!(h->heap =
|
if (!(h->heap =
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
__ast_calloc(1, h->avail_len * sizeof(void *), file, lineno, func)
|
__ast_calloc(1, h->avail_len * sizeof(void *), file, lineno, func)
|
||||||
#else
|
#else
|
||||||
ast_calloc(1, h->avail_len * sizeof(void *))
|
ast_calloc(1, h->avail_len * sizeof(void *))
|
||||||
|
@ -176,7 +176,7 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h)
|
||||||
* \brief Add a row of additional storage for the heap.
|
* \brief Add a row of additional storage for the heap.
|
||||||
*/
|
*/
|
||||||
static int grow_heap(struct ast_heap *h
|
static int grow_heap(struct ast_heap *h
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
, const char *file, int lineno, const char *func
|
, const char *file, int lineno, const char *func
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
|
@ -184,7 +184,7 @@ static int grow_heap(struct ast_heap *h
|
||||||
void **new_heap;
|
void **new_heap;
|
||||||
size_t new_len = h->avail_len * 2 + 1;
|
size_t new_len = h->avail_len * 2 + 1;
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func);
|
new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func);
|
||||||
#else
|
#else
|
||||||
new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
|
new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
|
||||||
|
@ -244,14 +244,14 @@ static int bubble_up(struct ast_heap *h, int i)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func)
|
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func)
|
||||||
#else
|
#else
|
||||||
int ast_heap_push(struct ast_heap *h, void *elm)
|
int ast_heap_push(struct ast_heap *h, void *elm)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (h->cur_len == h->avail_len && grow_heap(h
|
if (h->cur_len == h->avail_len && grow_heap(h
|
||||||
#ifdef MALLOC_DEBUG
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
, file, lineno, func
|
, file, lineno, func
|
||||||
#endif
|
#endif
|
||||||
)) {
|
)) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ ASTERISK_REGISTER_FILE()
|
||||||
* ast_str_append_va(...)
|
* ast_str_append_va(...)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
int __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
|
int __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
|
||||||
int append, const char *fmt, va_list ap, const char *file, int lineno, const char *function)
|
int append, const char *fmt, va_list ap, const char *file, int lineno, const char *function)
|
||||||
#else
|
#else
|
||||||
|
@ -112,7 +112,7 @@ int __ast_str_helper(struct ast_str **buf, ssize_t max_len,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
#ifdef __AST_DEBUG_MALLOC
|
||||||
_ast_str_make_space(buf, need, file, lineno, function)
|
_ast_str_make_space(buf, need, file, lineno, function)
|
||||||
#else
|
#else
|
||||||
ast_str_make_space(buf, need)
|
ast_str_make_space(buf, need)
|
||||||
|
|
Loading…
Reference in a new issue