aboutsummaryrefslogtreecommitdiffstats
path: root/channels/iax2-parser.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 18:06:51 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 18:06:51 +0000
commitdc23f1ac91002cfe29c5813ff094659442a06b12 (patch)
tree8e1b6122df789a718d3ce887d3ef68209c23066f /channels/iax2-parser.c
parentd8e6713a8b33706547afa94b2d4235a126c4e02b (diff)
don't do frame caching in LOW_MEMORY mode
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@49458 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/iax2-parser.c')
-rw-r--r--channels/iax2-parser.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index bb030d3d2..123f4925c 100644
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -50,10 +50,12 @@ static int frames = 0;
static int iframes = 0;
static int oframes = 0;
+#if !defined(LOW_MEMORY)
static void frame_cache_cleanup(void *data);
/*! \brief A per-thread cache of iax_frame structures */
AST_THREADSTORAGE_CUSTOM(frame_cache, frame_cache_init, frame_cache_cleanup);
+#endif
/*! \brief This is just so iax_frames, a list head struct for holding a list of
* iax_frame structures, is defined. */
@@ -940,6 +942,8 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
struct iax_frame *iax_frame_new(int direction, int datalen)
{
struct iax_frame *fr = NULL;
+
+#if !defined(LOW_MEMORY)
struct iax_frames *iax_frames;
/* Attempt to get a frame from this thread's cache */
@@ -955,6 +959,7 @@ struct iax_frame *iax_frame_new(int direction, int datalen)
}
AST_LIST_TRAVERSE_SAFE_END
}
+#endif
if (!fr) {
if (!(fr = ast_calloc_cache(1, sizeof(*fr) + datalen)))
@@ -975,7 +980,9 @@ struct iax_frame *iax_frame_new(int direction, int datalen)
void iax_frame_free(struct iax_frame *fr)
{
+#if !defined(LOW_MEMORY)
struct iax_frames *iax_frames;
+#endif
/* Note: does not remove from scheduler! */
if (fr->direction == DIRECTION_INGRESS)
@@ -986,17 +993,22 @@ void iax_frame_free(struct iax_frame *fr)
errorf("Attempt to double free frame detected\n");
return;
}
- fr->direction = 0;
ast_atomic_fetchadd_int(&frames, -1);
+#if !defined(LOW_MEMORY)
if (!(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
free(fr);
return;
}
+ fr->direction = 0;
AST_LIST_INSERT_HEAD(iax_frames, fr, list);
+#else
+ free(fr);
+#endif
}
+#if !defined(LOW_MEMORY)
static void frame_cache_cleanup(void *data)
{
struct iax_frames *frames = data;
@@ -1007,6 +1019,7 @@ static void frame_cache_cleanup(void *data)
free(frames);
}
+#endif
int iax_get_frames(void) { return frames; }
int iax_get_iframes(void) { return iframes; }