app_dial: Allow macro/gosub pre-bridge execution to occur on priorities
[asterisk/asterisk.git] / main / heap.c
index 929965f..c04f7a0 100644 (file)
  * \author Russell Bryant <russell@digium.com>
  */
 
+/*** MODULEINFO
+       <support_level>core</support_level>
+ ***/
+
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -177,18 +181,19 @@ static int grow_heap(struct ast_heap *h
 #endif
 )
 {
-       h->avail_len = h->avail_len * 2 + 1;
+       void **new_heap;
+       size_t new_len = h->avail_len * 2 + 1;
 
-       if (!(h->heap =
 #ifdef MALLOC_DEBUG
-                       __ast_realloc(h->heap, h->avail_len * sizeof(void *), file, lineno, func)
+       new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func);
 #else
-                       ast_realloc(h->heap, h->avail_len * sizeof(void *))
+       new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
 #endif
-               )) {
-               h->cur_len = h->avail_len = 0;
+       if (!new_heap) {
                return -1;
        }
+       h->heap = new_heap;
+       h->avail_len = new_len;
 
        return 0;
 }
@@ -308,15 +313,15 @@ size_t ast_heap_size(struct ast_heap *h)
 
 int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line)
 {
-       return __ast_rwlock_wrlock(&h->lock, "&h->lock", file, line, func);
+       return __ast_rwlock_wrlock(file, line, func, &h->lock, "&h->lock");
 }
 
 int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line)
 {
-       return __ast_rwlock_rdlock(&h->lock, "&h->lock", file, line, func);
+       return __ast_rwlock_rdlock(file, line, func, &h->lock, "&h->lock");
 }
 
 int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line)
 {
-       return __ast_rwlock_unlock(&h->lock, "&h->lock", file, line, func);
+       return __ast_rwlock_unlock(file, line, func, &h->lock, "&h->lock");
 }