summaryrefslogtreecommitdiffstats
path: root/lib/skin_parser
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-11-06 14:18:33 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-11-06 14:18:33 +0000
commitc98e525f297dd6757bf3c81ee6a625b86dbdecf5 (patch)
tree3979eb407693f7a3bb18bb457b406b557fe85951 /lib/skin_parser
parent781f05e40d987941e3ac374ea29083a4570c8394 (diff)
downloadrockbox-c98e525f297dd6757bf3c81ee6a625b86dbdecf5.tar.gz
rockbox-c98e525f297dd6757bf3c81ee6a625b86dbdecf5.tar.bz2
rockbox-c98e525f297dd6757bf3c81ee6a625b86dbdecf5.zip
Half the number of malloc() calls on APPLICATION builds in skin_buffer_alloc(). these are still presumably wasteing alot of RAM and could be merged further
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28520 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser')
-rw-r--r--lib/skin_parser/skin_buffer.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c
index 3c0870ea5a..0f72f768dd 100644
--- a/lib/skin_parser/skin_buffer.c
+++ b/lib/skin_parser/skin_buffer.c
@@ -63,8 +63,8 @@ static unsigned char *buffer_front = NULL;
#ifdef USE_HOST_MALLOC
struct malloc_object {
- void* object;
struct malloc_object *next;
+ char buf[0];
};
static struct malloc_object *malloced_head = NULL, *malloced_tail = NULL;
@@ -76,7 +76,6 @@ static void skin_free_malloced(void)
{
this = obj;
obj = this->next;
- free(this->object);
free(this);
}
malloced_head = NULL;
@@ -108,17 +107,16 @@ void* skin_buffer_alloc(size_t size)
retval = buffer_front;
buffer_front += size;
#elif defined(USE_HOST_MALLOC)
- struct malloc_object *obj = malloc(sizeof (struct malloc_object));
- if (!obj)
- return NULL;
- obj->object = malloc(size);
+ size_t malloc_size = sizeof(struct malloc_object) + size;
+ struct malloc_object *obj = malloc(malloc_size);
+ retval = &obj->buf;
obj->next = NULL;
if (malloced_tail == NULL)
malloced_head = malloced_tail = obj;
else
malloced_tail->next = obj;
malloced_tail = obj;
- retval = obj->object;
+
#else
retval = malloc(size);
#endif