[asterisk-commits] kpfleming: branch 1.4 r49461 -
/branches/1.4/main/frame.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jan 4 11:17:02 MST 2007
Author: kpfleming
Date: Thu Jan 4 12:17:01 2007
New Revision: 49461
URL: http://svn.digium.com/view/asterisk?view=rev&rev=49461
Log:
don't do frame header caching in the core if LOW_MEMORY is defined
Modified:
branches/1.4/main/frame.c
Modified: branches/1.4/main/frame.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/frame.c?view=diff&rev=49461&r1=49460&r2=49461
==============================================================================
--- branches/1.4/main/frame.c (original)
+++ branches/1.4/main/frame.c Thu Jan 4 12:17:01 2007
@@ -49,6 +49,7 @@
static AST_LIST_HEAD_STATIC(headerlist, ast_frame);
#endif
+#if !defined(LOW_MEMORY)
static void frame_cache_cleanup(void *data);
/*! \brief A per-thread cache of frame headers */
@@ -73,6 +74,7 @@
struct ast_frames list;
size_t size;
};
+#endif
#define SMOOTHER_SIZE 8000
@@ -284,6 +286,8 @@
static struct ast_frame *ast_frame_header_new(void)
{
struct ast_frame *f;
+
+#if !defined(LOW_MEMORY)
struct ast_frame_cache *frames;
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
@@ -296,6 +300,7 @@
return f;
}
}
+#endif
if (!(f = ast_calloc_cache(1, sizeof(*f))))
return NULL;
@@ -311,6 +316,7 @@
return f;
}
+#if !defined(LOW_MEMORY)
static void frame_cache_cleanup(void *data)
{
struct ast_frame_cache *frames = data;
@@ -321,12 +327,14 @@
free(frames);
}
+#endif
void ast_frame_free(struct ast_frame *fr, int cache)
{
if (!fr->mallocd)
return;
+#if !defined(LOW_MEMORY)
if (cache && fr->mallocd == AST_MALLOCD_HDR) {
/* Cool, only the header is malloc'd, let's just cache those for now
* to keep things simple... */
@@ -339,6 +347,7 @@
return;
}
}
+#endif
if (fr->mallocd & AST_MALLOCD_DATA) {
if (fr->data)
@@ -422,10 +431,13 @@
struct ast_frame *ast_frdup(const struct ast_frame *f)
{
- struct ast_frame_cache *frames;
struct ast_frame *out = NULL;
int len, srclen = 0;
void *buf = NULL;
+
+#if !defined(LOW_MEMORY)
+ struct ast_frame_cache *frames;
+#endif
/* Start with standard stuff */
len = sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
@@ -439,6 +451,7 @@
if (srclen > 0)
len += srclen + 1;
+#if !defined(LOW_MEMORY)
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
if (out->mallocd_hdr_len >= len) {
@@ -453,6 +466,8 @@
}
AST_LIST_TRAVERSE_SAFE_END
}
+#endif
+
if (!buf) {
if (!(buf = ast_calloc_cache(1, len)))
return NULL;
More information about the asterisk-commits
mailing list