[asterisk-commits] Fix checks for allocation debugging. (asterisk[11])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 24 16:53:10 CDT 2016
Joshua Colp has submitted this change and it was merged.
Change subject: Fix checks for allocation debugging.
......................................................................
Fix checks for allocation debugging.
MALLOC_DEBUG should not be used to check if debugging is actually
enabled, __AST_DEBUG_MALLOC should be used instead. MALLOC_DEBUG only
indicates that debugging is requested, __AST_DEBUG_MALLOC indicates it
is active.
Change-Id: I3ce9cdb6ec91b74ee1302941328462231be1ea53
---
M include/asterisk/chanvars.h
M include/asterisk/config.h
M include/asterisk/hashtab.h
M include/asterisk/heap.h
M include/asterisk/strings.h
M main/chanvars.c
M main/config.c
M main/hashtab.c
M main/heap.c
M main/strings.c
10 files changed, 47 insertions(+), 47 deletions(-)
Approvals:
Mark Michelson: Looks good to me, approved
Joshua Colp: Looks good to me, but someone else must approve; Verified
diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h
index 7ebc64a..a486cb7 100644
--- a/include/asterisk/chanvars.h
+++ b/include/asterisk/chanvars.h
@@ -33,7 +33,7 @@
AST_LIST_HEAD_NOLOCK(varshead, ast_var_t);
-#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);
#define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#else
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index 711a4f4..d6cb373 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -593,7 +593,7 @@
struct ast_variable *ast_category_detach_variables(struct ast_category *cat);
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);
#define ast_variable_new(a, b, c) _ast_variable_new(a, b, c, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#else
diff --git a/include/asterisk/hashtab.h b/include/asterisk/hashtab.h
index 17eff70..cfe035b 100644
--- a/include/asterisk/hashtab.h
+++ b/include/asterisk/hashtab.h
@@ -251,7 +251,7 @@
* \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
*/
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab * _ast_hashtab_create(int initial_buckets,
int (*compare)(const void *a, const void *b),
int (*resize)(struct ast_hashtab *),
@@ -294,7 +294,7 @@
* \retval 1 on success
* \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);
#define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
@@ -311,7 +311,7 @@
* \retval 1 on success
* \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);
#define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
@@ -324,7 +324,7 @@
* \retval 1 on success
* \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);
#define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
@@ -362,7 +362,7 @@
int ast_hashtab_capacity( struct ast_hashtab *tab);
/*! \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);
#define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#else
@@ -370,7 +370,7 @@
#endif
/*! \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);
#define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#else
@@ -395,7 +395,7 @@
/* ------------------ */
/*! \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);
#define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#else
diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h
index 86f4e3d..d1256b4 100644
--- a/include/asterisk/heap.h
+++ b/include/asterisk/heap.h
@@ -97,7 +97,7 @@
* \return An instance of a max heap
* \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,
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__)
@@ -126,7 +126,7 @@
* \retval non-zero failure
* \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);
#define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#else
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index 00f83b5..1cd5c80 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -397,7 +397,7 @@
* \note The result of this function is dynamically allocated memory, and must
* 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__)
AST_INLINE_API(
struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
@@ -552,7 +552,7 @@
/*!
* 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(
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function),
{
@@ -745,7 +745,7 @@
* through calling one of the other functions or macros defined in this
* 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 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__)
diff --git a/main/chanvars.c b/main/chanvars.c
index ed71a27..a6cd00c 100644
--- a/main/chanvars.c
+++ b/main/chanvars.c
@@ -35,7 +35,7 @@
#include "asterisk/strings.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)
#else
struct ast_var_t *ast_var_assign(const char *name, const char *value)
@@ -45,7 +45,7 @@
int name_len = strlen(name) + 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))) {
#else
if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
diff --git a/main/config.c b/main/config.c
index cfb5afb..4463253 100644
--- a/main/config.c
+++ b/main/config.c
@@ -276,7 +276,7 @@
static void ast_variable_destroy(struct ast_variable *doomed);
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)
#else
struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
@@ -293,7 +293,7 @@
}
if (
-#ifdef MALLOC_DEBUG
+#ifdef __AST_DEBUG_MALLOC
(variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func))
#else
(variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable)))
diff --git a/main/hashtab.c b/main/hashtab.c
index 9b334d4..d06d1e1 100644
--- a/main/hashtab.c
+++ b/main/hashtab.c
@@ -43,7 +43,7 @@
#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);
#define ast_hashtab_resize(a) _ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
@@ -218,7 +218,7 @@
}
struct ast_hashtab *
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
_ast_hashtab_create
#else
ast_hashtab_create
@@ -229,14 +229,14 @@
int (*newsize)(struct ast_hashtab *tab),
unsigned int (*hash)(const void *obj),
int do_locking
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
, const char *file, int lineno, const char *function
#endif
)
{
struct ast_hashtab *ht;
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function)))
#else
if (!(ht = ast_calloc(1, sizeof(*ht))))
@@ -246,7 +246,7 @@
while (!ast_is_prime(initial_buckets)) /* make sure this is prime */
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))) {
#else
if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) {
@@ -274,7 +274,7 @@
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)
#else
struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj))
@@ -287,7 +287,7 @@
return NULL;
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)
#else
ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)))
@@ -315,7 +315,7 @@
while (b) {
void *newobj = (*obj_dup_func)(b->object);
if (newobj)
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
_ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func);
#else
ast_hashtab_insert_immediate_bucket(ht, newobj, i);
@@ -426,7 +426,7 @@
}
}
-#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)
#else
int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
@@ -443,7 +443,7 @@
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);
#else
res = ast_hashtab_insert_immediate_bucket(tab, obj, h);
@@ -455,7 +455,7 @@
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)
#else
int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h)
@@ -474,7 +474,7 @@
tab->largest_bucket_size = c + 1;
if (!(b =
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(1, sizeof(*b), file, lineno, func)
#else
ast_calloc(1, sizeof(*b))
@@ -497,7 +497,7 @@
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)
#else
int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
@@ -513,7 +513,7 @@
ast_rwlock_wrlock(&tab->lock);
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);
#else
int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket);
@@ -636,7 +636,7 @@
/* 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 (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)
#else
static void ast_hashtab_resize(struct ast_hashtab *tab)
@@ -659,7 +659,7 @@
}
free(tab->array);
if (!(tab->array =
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func)
#else
ast_calloc(newsize, sizeof(*(tab->array)))
@@ -690,7 +690,7 @@
}
}
-#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)
#else
struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
@@ -700,7 +700,7 @@
struct ast_hashtab_iter *it;
if (!(it =
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(1, sizeof(*it), file, lineno, func)
#else
ast_calloc(1, sizeof(*it))
@@ -717,7 +717,7 @@
}
/* 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)
#else
struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab)
@@ -727,7 +727,7 @@
struct ast_hashtab_iter *it;
if (!(it =
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(1, sizeof(*it), file, lineno, func)
#else
ast_calloc(1, sizeof(*it))
diff --git a/main/heap.c b/main/heap.c
index c04f7a0..d40682a 100644
--- a/main/heap.c
+++ b/main/heap.c
@@ -111,7 +111,7 @@
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,
ssize_t index_offset, const char *file, int lineno, const char *func)
#else
@@ -131,7 +131,7 @@
}
if (!(h =
-#ifdef MALLOC_DEBUG
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(1, sizeof(*h), file, lineno, func)
#else
ast_calloc(1, sizeof(*h))
@@ -145,7 +145,7 @@
h->avail_len = (1 << init_height) - 1;
if (!(h->heap =
-#ifdef MALLOC_DEBUG
+#ifdef __AST_DEBUG_MALLOC
__ast_calloc(1, h->avail_len * sizeof(void *), file, lineno, func)
#else
ast_calloc(1, h->avail_len * sizeof(void *))
@@ -176,7 +176,7 @@
* \brief Add a row of additional storage for the heap.
*/
static int grow_heap(struct ast_heap *h
-#ifdef MALLOC_DEBUG
+#ifdef __AST_DEBUG_MALLOC
, const char *file, int lineno, const char *func
#endif
)
@@ -184,7 +184,7 @@
void **new_heap;
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);
#else
new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
@@ -244,14 +244,14 @@
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)
#else
int ast_heap_push(struct ast_heap *h, void *elm)
#endif
{
if (h->cur_len == h->avail_len && grow_heap(h
-#ifdef MALLOC_DEBUG
+#ifdef __AST_DEBUG_MALLOC
, file, lineno, func
#endif
)) {
diff --git a/main/strings.c b/main/strings.c
index e582012..c4335ea 100644
--- a/main/strings.c
+++ b/main/strings.c
@@ -52,7 +52,7 @@
* 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 append, const char *fmt, va_list ap, const char *file, int lineno, const char *function)
#else
@@ -88,7 +88,7 @@
need += 16 + need / 4;
}
if (
-#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#ifdef __AST_DEBUG_MALLOC
_ast_str_make_space(buf, need, file, lineno, function)
#else
ast_str_make_space(buf, need)
--
To view, visit https://gerrit.asterisk.org/3693
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ce9cdb6ec91b74ee1302941328462231be1ea53
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-commits
mailing list