diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/chanvars.c | 8 | ||||
-rw-r--r-- | main/config.c | 8 | ||||
-rw-r--r-- | main/hashtab.c | 24 |
3 files changed, 37 insertions, 3 deletions
diff --git a/main/chanvars.c b/main/chanvars.c index 14a89f767..670858937 100644 --- a/main/chanvars.c +++ b/main/chanvars.c @@ -31,13 +31,21 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/strings.h" #include "asterisk/utils.h" +#ifdef MALLOC_DEBUG +struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function) +#else struct ast_var_t *ast_var_assign(const char *name, const char *value) +#endif { struct ast_var_t *var; int name_len = strlen(name) + 1; int value_len = strlen(value) + 1; +#ifdef MALLOC_DEBUG + if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) { +#else if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) { +#endif return NULL; } diff --git a/main/config.c b/main/config.c index 986c81571..2055af396 100644 --- a/main/config.c +++ b/main/config.c @@ -230,14 +230,22 @@ struct ast_config_include { struct ast_config_include *next; /*!< ptr to next inclusion in the list */ }; +#ifdef MALLOC_DEBUG +struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno) +#else struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename) +#endif { struct ast_variable *variable; int name_len = strlen(name) + 1; int val_len = strlen(value) + 1; int fn_len = strlen(filename) + 1; +#ifdef MALLOC_DEBUG + if ((variable = __ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable), file, lineno, func))) { +#else if ((variable = ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) { +#endif char *dst = variable->stuff; /* writable space starts here */ variable->name = strcpy(dst, name); dst += name_len; diff --git a/main/hashtab.c b/main/hashtab.c index a6fac4e53..d60a78a0e 100644 --- a/main/hashtab.c +++ b/main/hashtab.c @@ -209,22 +209,40 @@ unsigned int ast_hashtab_hash_short(const short x) return x; } -struct ast_hashtab *ast_hashtab_create(int initial_buckets, +struct ast_hashtab * +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +_ast_hashtab_create +#else +ast_hashtab_create +#endif +(int initial_buckets, int (*compare)(const void *a, const void *b), int (*resize)(struct ast_hashtab *), int (*newsize)(struct ast_hashtab *tab), unsigned int (*hash)(const void *obj), - int do_locking) + int do_locking +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) + , const char *file, int lineno, const char *function +#endif +) { struct ast_hashtab *ht; - + +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) + if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function))) +#else if (!(ht = ast_calloc(1, sizeof(*ht)))) +#endif return NULL; while (!ast_is_prime(initial_buckets)) /* make sure this is prime */ initial_buckets++; +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) + if (!(ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), file, lineno, function))) { +#else if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) { +#endif free(ht); return NULL; } |