summaryrefslogtreecommitdiff
path: root/main/hashtab.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-10-14 22:38:06 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-10-14 22:38:06 +0000
commitd5837ba8c275b75388815a3263dae97cf306161b (patch)
tree96325674713833036b2bd7758905df5ccb47ca65 /main/hashtab.c
parentc6caf2a06fb2e316ac8b23561955ea95f7bc7598 (diff)
Add additional memory debugging to several core APIs, and fix several memory
leaks found with these changes. (Closes issue #13505, closes issue #13543) Reported by: mav3rick, triccyx Patches: 20081001__bug13505.diff.txt uploaded by Corydon76 (license 14) Tested by: mav3rick, triccyx git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@149199 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/hashtab.c')
-rw-r--r--main/hashtab.c24
1 files changed, 21 insertions, 3 deletions
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;
}