mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
conversions to allocation wrappers and various other coding guideliens fixes (issue #6582)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@11231 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -113,10 +113,9 @@ static void playtones_release(struct ast_channel *chan, void *params)
|
|||||||
static void * playtones_alloc(struct ast_channel *chan, void *params)
|
static void * playtones_alloc(struct ast_channel *chan, void *params)
|
||||||
{
|
{
|
||||||
struct playtones_def *pd = params;
|
struct playtones_def *pd = params;
|
||||||
struct playtones_state *ps = malloc(sizeof(struct playtones_state));
|
struct playtones_state *ps;
|
||||||
if (!ps)
|
if (!(ps = ast_calloc(1, sizeof(*ps))))
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(ps, 0, sizeof(struct playtones_state));
|
|
||||||
ps->origwfmt = chan->writeformat;
|
ps->origwfmt = chan->writeformat;
|
||||||
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
|
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
|
||||||
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
|
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
|
||||||
@@ -300,9 +299,7 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst,
|
|||||||
freq2 = 0;
|
freq2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.items = realloc(d.items,(d.nitems+1)*sizeof(struct playtones_item));
|
if (!(d.items = ast_realloc(d.items, (d.nitems + 1) * sizeof(*d.items)))) {
|
||||||
if (d.items == NULL) {
|
|
||||||
ast_log(LOG_WARNING, "Realloc failed!\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (freq1 / 8000.0)) * 32768.0;
|
d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (freq1 / 8000.0)) * 32768.0;
|
||||||
@@ -433,7 +430,7 @@ static inline void free_zone(struct tone_zone* zone)
|
|||||||
zone->tones = tmp;
|
zone->tones = tmp;
|
||||||
}
|
}
|
||||||
if (zone->ringcadence)
|
if (zone->ringcadence)
|
||||||
free((void*)zone->ringcadence);
|
free(zone->ringcadence);
|
||||||
free(zone);
|
free(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,18 +544,13 @@ int ast_register_indication(struct tone_zone *zone, const char *indication, cons
|
|||||||
}
|
}
|
||||||
if (!ts) {
|
if (!ts) {
|
||||||
/* not there, we have to add */
|
/* not there, we have to add */
|
||||||
ts = malloc(sizeof(struct tone_zone_sound));
|
if (!(ts = ast_malloc(sizeof(*ts)))) {
|
||||||
if (!ts) {
|
|
||||||
ast_log(LOG_WARNING, "Out of memory\n");
|
|
||||||
ast_mutex_unlock(&tzlock);
|
ast_mutex_unlock(&tzlock);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
ts->next = NULL;
|
ts->next = NULL;
|
||||||
}
|
}
|
||||||
ts->name = strdup(indication);
|
if (!(ts->name = ast_strdup(indication)) || !(ts->data = ast_strdup(tonelist))) {
|
||||||
ts->data = strdup(tonelist);
|
|
||||||
if (ts->name==NULL || ts->data==NULL) {
|
|
||||||
ast_log(LOG_WARNING, "Out of memory\n");
|
|
||||||
ast_mutex_unlock(&tzlock);
|
ast_mutex_unlock(&tzlock);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
36
io.c
36
io.c
@@ -36,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
#include "asterisk/io.h"
|
#include "asterisk/io.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
|
#include "asterisk/utils.h"
|
||||||
|
|
||||||
#ifdef DEBUG_IO
|
#ifdef DEBUG_IO
|
||||||
#define DEBUG DEBUG_M
|
#define DEBUG DEBUG_M
|
||||||
@@ -82,25 +83,19 @@ struct io_context *io_context_create(void)
|
|||||||
{
|
{
|
||||||
/* Create an I/O context */
|
/* Create an I/O context */
|
||||||
struct io_context *tmp;
|
struct io_context *tmp;
|
||||||
tmp = malloc(sizeof(struct io_context));
|
if ((tmp = ast_malloc(sizeof(*tmp)))) {
|
||||||
if (tmp) {
|
|
||||||
tmp->needshrink = 0;
|
tmp->needshrink = 0;
|
||||||
tmp->fdcnt = 0;
|
tmp->fdcnt = 0;
|
||||||
tmp->maxfdcnt = GROW_SHRINK_SIZE/2;
|
tmp->maxfdcnt = GROW_SHRINK_SIZE/2;
|
||||||
tmp->current_ioc = -1;
|
tmp->current_ioc = -1;
|
||||||
tmp->fds = malloc((GROW_SHRINK_SIZE/2) * sizeof(struct pollfd));
|
if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
|
||||||
if (!tmp->fds) {
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
} else {
|
} else {
|
||||||
memset(tmp->fds, 0, (GROW_SHRINK_SIZE / 2) * sizeof(struct pollfd));
|
if (!(tmp->ior = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) {
|
||||||
tmp->ior = malloc((GROW_SHRINK_SIZE / 2) * sizeof(struct io_rec));
|
|
||||||
if (!tmp->ior) {
|
|
||||||
free(tmp->fds);
|
free(tmp->fds);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
} else {
|
|
||||||
memset(tmp->ior, 0, (GROW_SHRINK_SIZE / 2) * sizeof(struct io_rec));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,25 +121,24 @@ static int io_grow(struct io_context *ioc)
|
|||||||
void *tmp;
|
void *tmp;
|
||||||
DEBUG(ast_log(LOG_DEBUG, "io_grow()\n"));
|
DEBUG(ast_log(LOG_DEBUG, "io_grow()\n"));
|
||||||
ioc->maxfdcnt += GROW_SHRINK_SIZE;
|
ioc->maxfdcnt += GROW_SHRINK_SIZE;
|
||||||
tmp = realloc(ioc->ior, (ioc->maxfdcnt + 1) * sizeof(struct io_rec));
|
if ((tmp = ast_realloc(ioc->ior, (ioc->maxfdcnt + 1) * sizeof(*ioc->ior)))) {
|
||||||
if (tmp) {
|
ioc->ior = tmp;
|
||||||
ioc->ior = (struct io_rec *)tmp;
|
if ((tmp = ast_realloc(ioc->fds, (ioc->maxfdcnt + 1) * sizeof(*ioc->fds)))) {
|
||||||
tmp = realloc(ioc->fds, (ioc->maxfdcnt + 1) * sizeof(struct pollfd));
|
|
||||||
if (tmp) {
|
|
||||||
ioc->fds = tmp;
|
ioc->fds = tmp;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Not enough memory for the pollfd. Not really any need
|
* Failed to allocate enough memory for the pollfd. Not
|
||||||
* to shrink back the iorec's as we'll probably want to
|
* really any need to shrink back the iorec's as we'll
|
||||||
* grow them again soon when more memory is available, and
|
* probably want to grow them again soon when more memory
|
||||||
* then they'll already be the right size
|
* is available, and then they'll already be the right size
|
||||||
*/
|
*/
|
||||||
ioc->maxfdcnt -= GROW_SHRINK_SIZE;
|
ioc->maxfdcnt -= GROW_SHRINK_SIZE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Out of memory. We return to the old size, and return a failure
|
* Memory allocation failure. We return to the old size, and
|
||||||
|
* return a failure
|
||||||
*/
|
*/
|
||||||
ioc->maxfdcnt -= GROW_SHRINK_SIZE;
|
ioc->maxfdcnt -= GROW_SHRINK_SIZE;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -180,10 +174,10 @@ int *ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events
|
|||||||
ioc->fds[ioc->fdcnt].revents = 0;
|
ioc->fds[ioc->fdcnt].revents = 0;
|
||||||
ioc->ior[ioc->fdcnt].callback = callback;
|
ioc->ior[ioc->fdcnt].callback = callback;
|
||||||
ioc->ior[ioc->fdcnt].data = data;
|
ioc->ior[ioc->fdcnt].data = data;
|
||||||
ioc->ior[ioc->fdcnt].id = (int *)malloc(sizeof(int));
|
if (!(ioc->ior[ioc->fdcnt].id = ast_malloc(sizeof(*ioc->ior[ioc->fdcnt].id)))) {
|
||||||
/* Bonk if we couldn't allocate an int */
|
/* Bonk if we couldn't allocate an int */
|
||||||
if (!ioc->ior[ioc->fdcnt].id)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
*(ioc->ior[ioc->fdcnt].id) = ioc->fdcnt;
|
*(ioc->ior[ioc->fdcnt].id) = ioc->fdcnt;
|
||||||
ret = ioc->ior[ioc->fdcnt].id;
|
ret = ioc->ior[ioc->fdcnt].id;
|
||||||
ioc->fdcnt++;
|
ioc->fdcnt++;
|
||||||
|
36
jitterbuf.c
36
jitterbuf.c
@@ -35,6 +35,7 @@
|
|||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include "jitterbuf.h"
|
#include "jitterbuf.h"
|
||||||
|
#include "asterisk/utils.h"
|
||||||
|
|
||||||
/*! define these here, just for ancient compiler systems */
|
/*! define these here, just for ancient compiler systems */
|
||||||
#define JB_LONGMAX 2147483647L
|
#define JB_LONGMAX 2147483647L
|
||||||
@@ -73,7 +74,7 @@ void jb_reset(jitterbuf *jb)
|
|||||||
{
|
{
|
||||||
/* only save settings */
|
/* only save settings */
|
||||||
jb_conf s = jb->info.conf;
|
jb_conf s = jb->info.conf;
|
||||||
memset(jb,0,sizeof(jitterbuf));
|
memset(jb, 0, sizeof(*jb));
|
||||||
jb->info.conf = s;
|
jb->info.conf = s;
|
||||||
|
|
||||||
/* initialize length */
|
/* initialize length */
|
||||||
@@ -85,9 +86,7 @@ jitterbuf * jb_new()
|
|||||||
{
|
{
|
||||||
jitterbuf *jb;
|
jitterbuf *jb;
|
||||||
|
|
||||||
|
if (!(jb = ast_malloc(sizeof(*jb))))
|
||||||
jb = malloc(sizeof(jitterbuf));
|
|
||||||
if (!jb)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
jb_reset(jb);
|
jb_reset(jb);
|
||||||
@@ -236,7 +235,7 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
|||||||
/* found where it fits */
|
/* found where it fits */
|
||||||
if (toins > jb->hist_maxbuf[j]) {
|
if (toins > jb->hist_maxbuf[j]) {
|
||||||
/* move over */
|
/* move over */
|
||||||
memmove(jb->hist_maxbuf+j+1,jb->hist_maxbuf+j, (JB_HISTORY_MAXBUF_SZ-(j+1)) * sizeof(long));
|
memmove(jb->hist_maxbuf + j + 1, jb->hist_maxbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_maxbuf[0]));
|
||||||
/* insert */
|
/* insert */
|
||||||
jb->hist_maxbuf[j] = toins;
|
jb->hist_maxbuf[j] = toins;
|
||||||
|
|
||||||
@@ -253,7 +252,7 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
|||||||
/* found where it fits */
|
/* found where it fits */
|
||||||
if (toins < jb->hist_minbuf[j]) {
|
if (toins < jb->hist_minbuf[j]) {
|
||||||
/* move over */
|
/* move over */
|
||||||
memmove(jb->hist_minbuf+j+1,jb->hist_minbuf+j, (JB_HISTORY_MAXBUF_SZ-(j+1)) * sizeof(long));
|
memmove(jb->hist_minbuf + j + 1, jb->hist_minbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_minbuf[0]));
|
||||||
/* insert */
|
/* insert */
|
||||||
jb->hist_minbuf[j] = toins;
|
jb->hist_minbuf[j] = toins;
|
||||||
|
|
||||||
@@ -321,21 +320,16 @@ static void history_get(jitterbuf *jb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* returns 1 if frame was inserted into head of queue, 0 otherwise */
|
/* returns 1 if frame was inserted into head of queue, 0 otherwise */
|
||||||
static int queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
|
static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts)
|
||||||
{
|
{
|
||||||
jb_frame *frame;
|
jb_frame *frame;
|
||||||
jb_frame *p;
|
jb_frame *p;
|
||||||
int head = 0;
|
int head = 0;
|
||||||
long resync_ts = ts - jb->info.resync_offset;
|
long resync_ts = ts - jb->info.resync_offset;
|
||||||
|
|
||||||
frame = jb->free;
|
if ((frame = jb->free)) {
|
||||||
if (frame) {
|
|
||||||
jb->free = frame->next;
|
jb->free = frame->next;
|
||||||
} else {
|
} else if (!(frame = ast_malloc(sizeof(*frame)))) {
|
||||||
frame = malloc(sizeof(jb_frame));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!frame) {
|
|
||||||
jb_err("cannot allocate frame\n");
|
jb_err("cannot allocate frame\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -514,7 +508,7 @@ static void jb_dbgqueue(jitterbuf *jb)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now)
|
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
|
||||||
{
|
{
|
||||||
jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
|
jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
|
||||||
|
|
||||||
@@ -535,7 +529,7 @@ int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
|
static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
|
||||||
{
|
{
|
||||||
jb_frame *frame;
|
jb_frame *frame;
|
||||||
long diff;
|
long diff;
|
||||||
@@ -775,9 +769,9 @@ long jb_next(jitterbuf *jb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
|
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
|
||||||
{
|
{
|
||||||
int ret = _jb_get(jb,frameout,now,interpl);
|
enum jb_return_code ret = _jb_get(jb, frameout, now, interpl);
|
||||||
#if 0
|
#if 0
|
||||||
static int lastts=0;
|
static int lastts=0;
|
||||||
int thists = ((ret == JB_OK) || (ret == JB_DROP)) ? frameout->ts : 0;
|
int thists = ((ret == JB_OK) || (ret == JB_DROP)) ? frameout->ts : 0;
|
||||||
@@ -791,7 +785,7 @@ int jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int jb_getall(jitterbuf *jb, jb_frame *frameout)
|
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
|
||||||
{
|
{
|
||||||
jb_frame *frame;
|
jb_frame *frame;
|
||||||
frame = queue_getall(jb);
|
frame = queue_getall(jb);
|
||||||
@@ -805,7 +799,7 @@ int jb_getall(jitterbuf *jb, jb_frame *frameout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int jb_getinfo(jitterbuf *jb, jb_info *stats)
|
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
|
||||||
{
|
{
|
||||||
|
|
||||||
history_get(jb);
|
history_get(jb);
|
||||||
@@ -815,7 +809,7 @@ int jb_getinfo(jitterbuf *jb, jb_info *stats)
|
|||||||
return JB_OK;
|
return JB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int jb_setconf(jitterbuf *jb, jb_conf *conf)
|
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
|
||||||
{
|
{
|
||||||
/* take selected settings from the struct */
|
/* take selected settings from the struct */
|
||||||
|
|
||||||
|
42
jitterbuf.h
42
jitterbuf.h
@@ -35,21 +35,23 @@ extern "C" {
|
|||||||
/* ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */
|
/* ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */
|
||||||
#define JB_ADJUST_DELAY 40
|
#define JB_ADJUST_DELAY 40
|
||||||
|
|
||||||
|
enum jb_return_code {
|
||||||
|
/* return codes */
|
||||||
|
JB_OK, /* 0 */
|
||||||
|
JB_EMPTY, /* 1 */
|
||||||
|
JB_NOFRAME, /* 2 */
|
||||||
|
JB_INTERP, /* 3 */
|
||||||
|
JB_DROP, /* 4 */
|
||||||
|
JB_SCHED /* 5 */
|
||||||
|
};
|
||||||
|
|
||||||
/* return codes */
|
enum jb_frame_type {
|
||||||
#define JB_OK 0
|
/* frame types */
|
||||||
#define JB_EMPTY 1
|
JB_TYPE_CONTROL, /* 0 */
|
||||||
#define JB_NOFRAME 2
|
JB_TYPE_VOICE, /* 1 */
|
||||||
#define JB_INTERP 3
|
JB_TYPE_VIDEO, /* 2 - reserved */
|
||||||
#define JB_DROP 4
|
JB_TYPE_SILENCE /* 3 */
|
||||||
#define JB_SCHED 5
|
};
|
||||||
|
|
||||||
/* frame types */
|
|
||||||
#define JB_TYPE_CONTROL 0
|
|
||||||
#define JB_TYPE_VOICE 1
|
|
||||||
#define JB_TYPE_VIDEO 2 /* reserved */
|
|
||||||
#define JB_TYPE_SILENCE 3
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct jb_conf {
|
typedef struct jb_conf {
|
||||||
/* settings */
|
/* settings */
|
||||||
@@ -88,7 +90,7 @@ typedef struct jb_frame {
|
|||||||
void *data; /* the frame data */
|
void *data; /* the frame data */
|
||||||
long ts; /* the relative delivery time expected */
|
long ts; /* the relative delivery time expected */
|
||||||
long ms; /* the time covered by this frame, in sec/8000 */
|
long ms; /* the time covered by this frame, in sec/8000 */
|
||||||
int type; /* the type of frame */
|
enum jb_frame_type type; /* the type of frame */
|
||||||
struct jb_frame *next, *prev;
|
struct jb_frame *next, *prev;
|
||||||
} jb_frame;
|
} jb_frame;
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ void jb_reset(jitterbuf *jb);
|
|||||||
* JB_DROP: Drop this frame immediately
|
* JB_DROP: Drop this frame immediately
|
||||||
* JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame
|
* JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame
|
||||||
*/
|
*/
|
||||||
int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now);
|
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now);
|
||||||
|
|
||||||
/* get a frame for time now (receiver's time) return value is one of
|
/* get a frame for time now (receiver's time) return value is one of
|
||||||
* JB_OK: You've got frame!
|
* JB_OK: You've got frame!
|
||||||
@@ -134,20 +136,20 @@ int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now);
|
|||||||
* JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame)
|
* JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame)
|
||||||
* JB_EMPTY: The jb is empty.
|
* JB_EMPTY: The jb is empty.
|
||||||
*/
|
*/
|
||||||
int jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl);
|
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl);
|
||||||
|
|
||||||
/* unconditionally get frames from jitterbuf until empty */
|
/* unconditionally get frames from jitterbuf until empty */
|
||||||
int jb_getall(jitterbuf *jb, jb_frame *frameout);
|
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout);
|
||||||
|
|
||||||
/* when is the next frame due out, in receiver's time (0=EMPTY)
|
/* when is the next frame due out, in receiver's time (0=EMPTY)
|
||||||
* This value may change as frames are added (esp non-audio frames) */
|
* This value may change as frames are added (esp non-audio frames) */
|
||||||
long jb_next(jitterbuf *jb);
|
long jb_next(jitterbuf *jb);
|
||||||
|
|
||||||
/* get jitterbuf info: only "statistics" may be valid */
|
/* get jitterbuf info: only "statistics" may be valid */
|
||||||
int jb_getinfo(jitterbuf *jb, jb_info *stats);
|
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats);
|
||||||
|
|
||||||
/* set jitterbuf conf */
|
/* set jitterbuf conf */
|
||||||
int jb_setconf(jitterbuf *jb, jb_conf *conf);
|
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
|
||||||
|
|
||||||
typedef void (*jb_output_function_t)(const char *fmt, ...);
|
typedef void (*jb_output_function_t)(const char *fmt, ...);
|
||||||
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
|
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
|
||||||
|
12
loader.c
12
loader.c
@@ -50,6 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
#include "asterisk/md5.h"
|
#include "asterisk/md5.h"
|
||||||
|
#include "asterisk/utils.h"
|
||||||
|
|
||||||
#ifndef RTLD_NOW
|
#ifndef RTLD_NOW
|
||||||
#define RTLD_NOW 0
|
#define RTLD_NOW 0
|
||||||
@@ -290,8 +291,7 @@ static void *find_symbol(struct module *m, const char *name, int verbose)
|
|||||||
|
|
||||||
if (name[0] == '_')
|
if (name[0] == '_')
|
||||||
name++;
|
name++;
|
||||||
n1 = alloca(strlen(name)+2); /* room for leading '_' and final '\0' */
|
if (!(n1 = alloca(strlen(name) + 2))) /* room for leading '_' and final '\0' */
|
||||||
if (n1 == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
n1[0] = '_';
|
n1[0] = '_';
|
||||||
strcpy(n1+1, name);
|
strcpy(n1+1, name);
|
||||||
@@ -341,9 +341,7 @@ static int __load_resource(const char *resource_name, const struct ast_config *c
|
|||||||
AST_LIST_UNLOCK(&module_list);
|
AST_LIST_UNLOCK(&module_list);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cur = calloc(1, sizeof(struct module));
|
if (!(cur = ast_calloc(1, sizeof(*cur)))) {
|
||||||
if (!cur) {
|
|
||||||
ast_log(LOG_WARNING, "Out of memory\n");
|
|
||||||
AST_LIST_UNLOCK(&module_list);
|
AST_LIST_UNLOCK(&module_list);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -582,8 +580,8 @@ int ast_update_module_list(int (*modentry)(const char *module, const char *descr
|
|||||||
int ast_loader_register(int (*v)(void))
|
int ast_loader_register(int (*v)(void))
|
||||||
{
|
{
|
||||||
/* XXX Should be more flexible here, taking > 1 verboser XXX */
|
/* XXX Should be more flexible here, taking > 1 verboser XXX */
|
||||||
struct loadupdate *tmp = malloc(sizeof (struct loadupdate));
|
struct loadupdate *tmp;
|
||||||
if (!tmp)
|
if (!(tmp = ast_malloc(sizeof(*tmp))))
|
||||||
return -1;
|
return -1;
|
||||||
tmp->updater = v;
|
tmp->updater = v;
|
||||||
if (AST_LIST_LOCK(&module_list))
|
if (AST_LIST_LOCK(&module_list))
|
||||||
|
Reference in New Issue
Block a user