1
0
Fork 0
forked from len0rd/rockbox

lua: Switch memory allocator from dl to tlsf

Instead of providing yet another memory allocator implementation
use tlsf and simply link tlsf library.

Another small improvement is to *grow* memory pool by grabbing
audiobuffer instead of just switching to use audiobuf exclusively.
Tested with simple lua 'memory eater' script.

This patch extends tlsf lib slightly. You can provide
void *get_new_area(size_t * size) function which will override
weak dummy implementation provided in lib itself. This allows to
automaticaly initialize memory pool as well as grow memory
pool if needed (for example grab audiobuffer when pluginbuffer
is exhaused).

Change-Id: I841af6b6b5bbbf546c14cbf139a7723fbb982f1b
This commit is contained in:
Marcin Bukat 2013-08-22 12:12:47 +02:00
parent b2e80edd16
commit a2a2e14e0d
10 changed files with 50 additions and 5173 deletions

View file

@ -23,6 +23,7 @@
#define _ROCKCONF_H_
#include "plugin.h"
#include <tlsf.h>
#undef LUAI_THROW
#undef LUAI_TRY
@ -40,9 +41,6 @@
#define luai_jmpbuf jmp_buf
extern char curpath[MAX_PATH];
void* dlmalloc(size_t bytes);
void *dlrealloc(void *ptr, size_t size);
void dlfree(void *ptr);
struct tm *gmtime(const time_t *timep);
long strtol(const char *nptr, char **endptr, int base);
unsigned long strtoul(const char *str, char **endptr, int base);
@ -54,8 +52,9 @@ long lpow(long x, long y);
#define pow lpow
/* Simple substitutions */
#define realloc dlrealloc
#define free dlfree
#define malloc tlsf_malloc
#define realloc tlsf_realloc
#define free tlsf_free
#define memchr rb->memchr
#define snprintf rb->snprintf
#define strcat rb->strcat