]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
replace all malloc calls to zap_malloc
authorMoises Silva <moy@sangoma.com>
Sun, 15 Nov 2009 02:14:50 +0000 (02:14 +0000)
committerMoises Silva <moy@sangoma.com>
Sun, 15 Nov 2009 02:14:50 +0000 (02:14 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@862 a93c3328-9c30-0410-af19-c9cd2b2d52af

16 files changed:
libs/freetdm/src/fsk.c
libs/freetdm/src/hashtable.c
libs/freetdm/src/include/openzap.h
libs/freetdm/src/isdn/Q921.c
libs/freetdm/src/libteletone_generate.c
libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c
libs/freetdm/src/ozmod/ozmod_analog_em/ozmod_analog_em.c
libs/freetdm/src/ozmod/ozmod_isdn/ozmod_isdn.c
libs/freetdm/src/ozmod/ozmod_libpri/ozmod_libpri.c
libs/freetdm/src/ozmod/ozmod_pika/ozmod_pika.c
libs/freetdm/src/ozmod/ozmod_r2/ozmod_r2.c
libs/freetdm/src/uart.c
libs/freetdm/src/zap_buffer.c
libs/freetdm/src/zap_io.c
libs/freetdm/src/zap_m3ua.c
libs/freetdm/src/zap_threadmutex.c

index 773b0deaae722ec46ba14fa105f3298c2ae218dd..f55d42155970d63e21fcf42aa619a549f7e3c347 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     2005 03 20      R. Krten                created
 */
-
+#include <openzap.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -134,7 +134,7 @@ dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
        double                                  phi_mark, phi_space;
        dsp_fsk_handle_t        *handle;
 
-       handle = malloc(sizeof(*handle));
+       handle = zap_malloc(sizeof(*handle));
        if (!handle) {
                return NULL;
        }
@@ -157,7 +157,7 @@ dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
 
        /* allocate the correlation sin/cos arrays and initialize */
        for (i = 0; i < 4; i++) {
-               handle->correlates[i] = malloc(sizeof(double) * handle->corrsize);
+               handle->correlates[i] = zap_malloc(sizeof(double) * handle->corrsize);
                if (handle->correlates[i] == NULL) {
                        /* some failed, back out memory allocations */
                        dsp_fsk_destroy(&handle);
@@ -177,7 +177,7 @@ dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
        }
 
        /* initialize the ring buffer */
-       handle->buffer = malloc(sizeof(double) * handle->corrsize);
+       handle->buffer = zap_malloc(sizeof(double) * handle->corrsize);
        if (!handle->buffer) {                          /* failed; back out memory allocations */
                dsp_fsk_destroy(&handle);
                return NULL;
index eeb2aaa07ac20cfbc05de72c815a7ec7734d8d7d..415dda7d8dbe51f65bbfe9f07ece17b60d1cf80a 100644 (file)
@@ -31,6 +31,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "openzap.h"
 #include "hashtable.h"
 #include "hashtable_private.h"
 #include <stdlib.h>
@@ -69,9 +70,9 @@ create_hashtable(unsigned int minsize,
     for (pindex=0; pindex < prime_table_length; pindex++) {
         if (primes[pindex] > minsize) { size = primes[pindex]; break; }
     }
-    h = (struct hashtable *)malloc(sizeof(struct hashtable));
+    h = (struct hashtable *)zap_malloc(sizeof(struct hashtable));
     if (NULL == h) return NULL; /*oom*/
-    h->table = (struct entry **)malloc(sizeof(struct entry*) * size);
+    h->table = (struct entry **)zap_malloc(sizeof(struct entry*) * size);
     if (NULL == h->table) { free(h); return NULL; } /*oom*/
     memset(h->table, 0, size * sizeof(struct entry *));
     h->tablelength  = size;
@@ -110,7 +111,7 @@ hashtable_expand(struct hashtable *h)
     if (h->primeindex == (prime_table_length - 1)) return 0;
     newsize = primes[++(h->primeindex)];
 
-    newtable = (struct entry **)malloc(sizeof(struct entry*) * newsize);
+    newtable = (struct entry **)zap_malloc(sizeof(struct entry*) * newsize);
     if (NULL != newtable)
                {
                        memset(newtable, 0, newsize * sizeof(struct entry *));
@@ -178,7 +179,7 @@ hashtable_insert(struct hashtable *h, void *k, void *v, hashtable_flag_t flags)
                         * element may be ok. Next time we insert, we'll try expanding again.*/
                        hashtable_expand(h);
                }
-    e = (struct entry *)malloc(sizeof(struct entry));
+    e = (struct entry *)zap_malloc(sizeof(struct entry));
     if (NULL == e) { --(h->entrycount); return 0; } /*oom*/
     e->h = hash(h,k);
     index = indexFor(h->tablelength,e->h);
index bdd97ca591e24fab011bc5523ae655626e4f6431..726cee3b0969fcc119972efdb9f05944820edc77 100644 (file)
@@ -753,19 +753,19 @@ ZIO_CODEC_FUNCTION(zio_alaw2ulaw);
   \brief Allocate uninitialized memory
   \command chunksize the chunk size
 */
-#define zap_malloc(chunksize) g_zap_mem_handler.malloc(g_zap_mem_handler.pool, chunksize);
+#define zap_malloc(chunksize) g_zap_mem_handler.malloc(g_zap_mem_handler.pool, chunksize)
 
 /*!
   \brief Allocate initialized memory
   \command chunksize the chunk size
 */
-#define zap_calloc(elements, chunksize) g_zap_mem_handler.calloc(g_zap_mem_handler.pool, elements, chunksize);
+#define zap_calloc(elements, chunksize) g_zap_mem_handler.calloc(g_zap_mem_handler.pool, elements, chunksize)
 
 /*!
   \brief Free chunk of memory
   \command chunksize the chunk size
 */
-#define zap_free(chunk) g_zap_mem_handler.free(g_zap_mem_handler.pool, chunk);
+#define zap_free(chunk) g_zap_mem_handler.free(g_zap_mem_handler.pool, chunk)
 
 /*!
   \brief Free a pointer and set it to NULL unless it already is NULL
index 0496e09f5c687cc1e072dccc739ee9fc1305515f..9cfd08a07c3276804099dc51dc8c004b298d7d4b 100644 (file)
@@ -79,6 +79,7 @@
 #include <string.h>
 #include <stdarg.h>
 
+#include "openzap.h"
 #include "Q921.h"
 #include "Q921priv.h"
 #include "mfifo.h"
@@ -397,7 +398,7 @@ int Q921_InitTrunk(L2TRUNK trunk,
                /*
                 * Allocate space for per-link context(s)
                 */
-               trunk->context = malloc(numlinks * sizeof(struct Q921_Link));
+               trunk->context = zap_malloc(numlinks * sizeof(struct Q921_Link));
                if(!trunk->context)
                        return -1;
 
index 1d5d696af2ec780b51ca3f1f57356e3853557ed2..d0ae2b01e357411e5f619500506829129dc6e3f1 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include <libteletone.h>
+#include "openzap.h"
 
 #define SMAX 32767
 #define SMIN -32768
@@ -273,7 +274,7 @@ TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone
 static char *my_strdup (const char *s)
 {
        size_t len = strlen (s) + 1;
-       void *new = malloc (len);
+       void *new = zap_malloc(len);
        
        if (new == NULL) {
                return NULL;
index 3978c94106b8751e8eed858e3550a5d86334b33f..4da3e2e5641f0ba73e062c12a4de86d11f13be5b 100644 (file)
@@ -122,7 +122,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
                return ZAP_FAIL;
        }
        
-       analog_data = malloc(sizeof(*analog_data));
+       analog_data = zap_malloc(sizeof(*analog_data));
        assert(analog_data != NULL);
        memset(analog_data, 0, sizeof(*analog_data));
 
index 4468e4b92d3168f0894eb40adc278e1c976a18f7..53bf1a000f8402f0832e757325bfb735981f89a7 100644 (file)
@@ -106,7 +106,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_em_configure_span)
                return ZAP_FAIL;
        }
        
-       analog_data = malloc(sizeof(*analog_data));
+       analog_data = zap_malloc(sizeof(*analog_data));
        assert(analog_data != NULL);
        memset(analog_data, 0, sizeof(*analog_data));
 
index d054bd08d1d98e9ae7e407643be1ad99402a1592..a92877ca14d30246f042c5e2b5b665566c525ac3 100644 (file)
@@ -2263,7 +2263,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
                return ZAP_FAIL;
        }
 
-       isdn_data = malloc(sizeof(*isdn_data));
+       isdn_data = zap_malloc(sizeof(*isdn_data));
        assert(isdn_data != NULL);
        memset(isdn_data, 0, sizeof(*isdn_data));
        
@@ -2333,7 +2333,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
        if (isdn_data->mode == Q931_NT) {
                zap_isdn_bchan_data_t *data;
 
-               data = malloc((span->chan_count - 1) * sizeof(zap_isdn_bchan_data_t));
+               data = zap_malloc((span->chan_count - 1) * sizeof(zap_isdn_bchan_data_t));
                if (!data) {
                        return ZAP_FAIL;
                }
index a8e3fea6f72e8809231ce617a8335c6d9e53b870..e80de2686d0d54df49b319a95f29224975fb898c 100644 (file)
@@ -1272,7 +1272,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_libpri_configure_span)
        }
 #endif
 
-       isdn_data = malloc(sizeof(*isdn_data));
+       isdn_data = zap_malloc(sizeof(*isdn_data));
        assert(isdn_data != NULL);
        memset(isdn_data, 0, sizeof(*isdn_data));
 
index 154c1618ff0479725b5eac602fdc3c0026ba018a..536110c32a2427eca74b94b6e3bf4bbf6fe6ae59 100644 (file)
@@ -156,7 +156,7 @@ static ZIO_CONFIGURE_FUNCTION(pika_configure)
        int ok = 1;
 
        if (!(profile = (pika_channel_profile_t *) hashtable_search(globals.profile_hash, (char *)category))) {
-               profile = malloc(sizeof(*profile));
+               profile = zap_malloc(sizeof(*profile));
                memset(profile, 0, sizeof(*profile));
                zap_set_string(profile->name, category);
                profile->ec_config = globals.ec_config;
@@ -348,7 +348,7 @@ static unsigned pika_open_range(zap_span_t *span, unsigned boardno, unsigned spa
        if (span->mod_data) {
                span_data = span->mod_data;
        } else {
-               span_data = malloc(sizeof(*span_data));
+               span_data = zap_malloc(sizeof(*span_data));
                assert(span_data != NULL);
                memset(span_data, 0, sizeof(*span_data));
                span_data->boardno = boardno;
@@ -376,7 +376,7 @@ static unsigned pika_open_range(zap_span_t *span, unsigned boardno, unsigned spa
                zap_channel_t *chan;
                pika_chan_data_t *chan_data = NULL;
 
-               chan_data = malloc(sizeof *chan_data);
+               chan_data = zap_malloc(sizeof *chan_data);
                assert(chan_data);
                memset(chan_data, 0, sizeof(*chan_data));
                zap_span_add_channel(span, 0, type, &chan);
index 9683aa57b23f5a6482f75e43f06ec4854b3027a7..837a8887b75d9814f4eb8f9cba47de1d1f87e05c 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <stdio.h>
-#include <pthread.h>
 #include <openr2.h>
 #include "openzap.h"
 
@@ -738,7 +737,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_r2_configure_span)
                        }
                        openr2_log_level_t tmplevel;
                        char *clevel;
-                       char *logval = malloc(strlen(val)+1); /* alloca man page scared me, so better to use good ol' malloc  */
+                       char *logval = zap_malloc(strlen(val)+1); /* alloca man page scared me, so better to use good ol' malloc  */
                        if (!logval) {
                                zap_log(ZAP_LOG_WARNING, "Ignoring R2 logging parameter: '%s', failed to alloc memory\n", val);
                                continue;
@@ -811,14 +810,14 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_r2_configure_span)
                return ZAP_FAIL;
        }
 
-       r2data = malloc(sizeof(*r2data));
+       r2data = zap_malloc(sizeof(*r2data));
        if (!r2data) {
                snprintf(span->last_error, sizeof(span->last_error), "Failed to allocate R2 data.");
                return ZAP_FAIL;
        }
        memset(r2data, 0, sizeof(*r2data));
 
-       spanpvt = malloc(sizeof(*spanpvt));
+       spanpvt = zap_malloc(sizeof(*spanpvt));
        if (!spanpvt) {
                snprintf(span->last_error, sizeof(span->last_error), "Failed to allocate private span data container.");
                goto fail;
@@ -862,7 +861,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_r2_configure_span)
                        openr2_chan_set_log_level(r2chan, r2conf.loglevel);
                }
 
-               r2call = malloc(sizeof(*r2call));
+               r2call = zap_malloc(sizeof(*r2call));
                if (!r2call) {
                        snprintf(span->last_error, sizeof(span->last_error), "Cannot create all R2 call data structures for the span.");
                        zap_safe_free(r2chan);
index 5e0dd853505c0a53ffec3ddf7259ff5d3e90b9d5..14f066da5977ff554b82135fa93d36b49c5402f0 100644 (file)
@@ -32,6 +32,7 @@
  *     2005 06 11      R. Krten                created
 */
 
+#include <openzap.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -76,7 +77,7 @@ dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr)
 {
        dsp_uart_handle_t *handle;
 
-       handle = malloc(sizeof (*handle));
+       handle = zap_malloc(sizeof (*handle));
        if (handle) {
                memset(handle, 0, sizeof (*handle));
 
index 0e2279d7e395d4c40b648e902ed43919f3bb31fd..bd8b0cc3071265e3786bd623c80d26a3f9c673ea 100644 (file)
@@ -53,12 +53,12 @@ OZ_DECLARE(zap_status_t) zap_buffer_create(zap_buffer_t **buffer, zap_size_t blo
 {
        zap_buffer_t *new_buffer;
 
-       new_buffer = malloc(sizeof(*new_buffer));
+       new_buffer = zap_malloc(sizeof(*new_buffer));
        if (new_buffer) {
                memset(new_buffer, 0, sizeof(*new_buffer));
 
                if (start_len) {
-                       new_buffer->data = malloc(start_len);
+                       new_buffer->data = zap_malloc(start_len);
                        if (!new_buffer->data) {
                                free(new_buffer);
                                return ZAP_MEMERR;
index cc4ebb7f423cb83d80ba5a71d4c0a407b0d76a92..4a20acf65ff261ab2466067617b573c6a41aa2a1 100644 (file)
@@ -35,8 +35,6 @@
 #ifndef WIN32
 #endif
 #include "openzap.h"
-//#include "zap_isdn.h"
-//#include "zap_ss7_boost.h"
 #include <stdarg.h>
 #ifdef WIN32
 #include <io.h>
@@ -426,7 +424,7 @@ OZ_DECLARE(zap_status_t) zap_span_create(zap_io_interface_t *zio, zap_span_t **s
        zap_mutex_lock(globals.mutex);
 
        if (globals.span_index < ZAP_MAX_SPANS_INTERFACE) {
-               new_span = malloc(sizeof(*new_span));
+               new_span = zap_malloc(sizeof(*new_span));
                assert(new_span);
                memset(new_span, 0, sizeof(*new_span));
                status = zap_mutex_create(&new_span->mutex);
@@ -554,7 +552,7 @@ OZ_DECLARE(zap_status_t) zap_span_add_channel(zap_span_t *span, zap_socket_t soc
                zap_channel_t *new_chan = span->channels[++span->chan_count];
 
                if (!new_chan) {
-                       if (!(new_chan = malloc(sizeof(*new_chan)))) {
+                       if (!(new_chan = zap_malloc(sizeof(*new_chan)))) {
                                return ZAP_FAIL;
                        }
                        span->channels[span->chan_count] = new_chan;
@@ -3112,7 +3110,7 @@ OZ_DECLARE(int) zap_vasprintf(char **ret, const char *fmt, va_list ap) /* code f
 
        len = vsnprintf(tmp, 0, fmt, ap2);
 
-       if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
+       if (len > 0 && (buf = zap_malloc((buflen = (size_t) (len + 1)))) != NULL) {
                len = vsnprintf(buf, buflen, fmt, ap);
                *ret = buf;
        } else {
index 50736b75e4da089034d3615421e4adb2865137e9..8e572c92d7f5d399cbc9d357d17849bbc501e191 100644 (file)
@@ -399,7 +399,7 @@ static ZIO_CONFIGURE_FUNCTION(m3ua_configure)
        int ok = 1;
 
        if (!(profile = (m3ua_channel_profile_t *) hashtable_search(globals.profile_hash, (char *)category))) {
-               profile = malloc(sizeof(*profile));
+               profile = zap_malloc(sizeof(*profile));
                memset(profile, 0, sizeof(*profile));
                zap_set_string(profile->name, category);
                hashtable_insert(globals.profile_hash, (void *)profile->name, profile);
index fa302e56a6db6398ec2d53395a1ec195bb51a4ed..d4a12f4186b84a3ab9f56c9b2fc704fae3f07f87 100644 (file)
@@ -99,7 +99,7 @@ OZ_DECLARE(zap_status_t) zap_thread_create_detached_ex(zap_thread_function_t fun
        zap_thread_t *thread = NULL;
        zap_status_t status = ZAP_FAIL;
 
-       if (!func || !(thread = (zap_thread_t *)malloc(sizeof(zap_thread_t)))) {
+       if (!func || !(thread = (zap_thread_t *)zap_malloc(sizeof(zap_thread_t)))) {
                goto done;
        }
 
@@ -149,7 +149,7 @@ OZ_DECLARE(zap_status_t) zap_mutex_create(zap_mutex_t **mutex)
 #endif
        zap_mutex_t *check = NULL;
 
-       check = (zap_mutex_t *)malloc(sizeof(**mutex));
+       check = (zap_mutex_t *)zap_malloc(sizeof(**mutex));
        if (!check)
                goto done;
 #ifdef WIN32
@@ -242,7 +242,7 @@ OZ_DECLARE(zap_status_t) zap_condition_create(zap_condition_t **incondition, zap
        return ZAP_NOTIMPL;
 #endif
 
-       condition = malloc(sizeof(*condition));
+       condition = zap_malloc(sizeof(*condition));
        if (!condition) {
                return ZAP_FAIL;
        }