*
* 2005 03 20 R. Krten created
*/
-
+#include <openzap.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
double phi_mark, phi_space;
dsp_fsk_handle_t *handle;
- handle = malloc(sizeof(*handle));
+ handle = zap_malloc(sizeof(*handle));
if (!handle) {
return NULL;
}
/* 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);
}
/* 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;
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "openzap.h"
#include "hashtable.h"
#include "hashtable_private.h"
#include <stdlib.h>
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;
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 *));
* 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);
\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
#include <string.h>
#include <stdarg.h>
+#include "openzap.h"
#include "Q921.h"
#include "Q921priv.h"
#include "mfifo.h"
/*
* 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;
*/
#include <libteletone.h>
+#include "openzap.h"
#define SMAX 32767
#define SMIN -32768
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;
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));
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));
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));
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;
}
}
#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));
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;
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;
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);
*/
#include <stdio.h>
-#include <pthread.h>
#include <openr2.h>
#include "openzap.h"
}
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;
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;
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);
* 2005 06 11 R. Krten created
*/
+#include <openzap.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
{
dsp_uart_handle_t *handle;
- handle = malloc(sizeof (*handle));
+ handle = zap_malloc(sizeof (*handle));
if (handle) {
memset(handle, 0, sizeof (*handle));
{
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;
#ifndef WIN32
#endif
#include "openzap.h"
-//#include "zap_isdn.h"
-//#include "zap_ss7_boost.h"
#include <stdarg.h>
#ifdef WIN32
#include <io.h>
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);
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;
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 {
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);
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;
}
#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
return ZAP_NOTIMPL;
#endif
- condition = malloc(sizeof(*condition));
+ condition = zap_malloc(sizeof(*condition));
if (!condition) {
return ZAP_FAIL;
}