forked from len0rd/rockbox
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
This commit is contained in:
parent
781f05e40d
commit
c98e525f29
1 changed files with 5 additions and 7 deletions
|
|
@ -63,8 +63,8 @@ static unsigned char *buffer_front = NULL;
|
||||||
#ifdef USE_HOST_MALLOC
|
#ifdef USE_HOST_MALLOC
|
||||||
|
|
||||||
struct malloc_object {
|
struct malloc_object {
|
||||||
void* object;
|
|
||||||
struct malloc_object *next;
|
struct malloc_object *next;
|
||||||
|
char buf[0];
|
||||||
};
|
};
|
||||||
static struct malloc_object *malloced_head = NULL, *malloced_tail = NULL;
|
static struct malloc_object *malloced_head = NULL, *malloced_tail = NULL;
|
||||||
|
|
||||||
|
|
@ -76,7 +76,6 @@ static void skin_free_malloced(void)
|
||||||
{
|
{
|
||||||
this = obj;
|
this = obj;
|
||||||
obj = this->next;
|
obj = this->next;
|
||||||
free(this->object);
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
malloced_head = NULL;
|
malloced_head = NULL;
|
||||||
|
|
@ -108,17 +107,16 @@ void* skin_buffer_alloc(size_t size)
|
||||||
retval = buffer_front;
|
retval = buffer_front;
|
||||||
buffer_front += size;
|
buffer_front += size;
|
||||||
#elif defined(USE_HOST_MALLOC)
|
#elif defined(USE_HOST_MALLOC)
|
||||||
struct malloc_object *obj = malloc(sizeof (struct malloc_object));
|
size_t malloc_size = sizeof(struct malloc_object) + size;
|
||||||
if (!obj)
|
struct malloc_object *obj = malloc(malloc_size);
|
||||||
return NULL;
|
retval = &obj->buf;
|
||||||
obj->object = malloc(size);
|
|
||||||
obj->next = NULL;
|
obj->next = NULL;
|
||||||
if (malloced_tail == NULL)
|
if (malloced_tail == NULL)
|
||||||
malloced_head = malloced_tail = obj;
|
malloced_head = malloced_tail = obj;
|
||||||
else
|
else
|
||||||
malloced_tail->next = obj;
|
malloced_tail->next = obj;
|
||||||
malloced_tail = obj;
|
malloced_tail = obj;
|
||||||
retval = obj->object;
|
|
||||||
#else
|
#else
|
||||||
retval = malloc(size);
|
retval = malloc(size);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue