diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2013-08-22 12:12:47 +0200 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2013-08-26 09:42:47 +0200 |
commit | a2a2e14e0d400e1c82b4d02c4399602488578dc6 (patch) | |
tree | 87e63279ef95ce06315b492d85a009b58f3782b2 /apps/plugins/lua/rockconf.h | |
parent | b2e80edd1671833dc80eb0c5334cb6a2c58808e0 (diff) | |
download | rockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.tar.gz rockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.zip |
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
Diffstat (limited to 'apps/plugins/lua/rockconf.h')
-rw-r--r-- | apps/plugins/lua/rockconf.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h index c0a233135a..a13146d7e9 100644 --- a/apps/plugins/lua/rockconf.h +++ b/apps/plugins/lua/rockconf.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #define _ROCKCONF_H_ | 23 | #define _ROCKCONF_H_ |
24 | 24 | ||
25 | #include "plugin.h" | 25 | #include "plugin.h" |
26 | #include <tlsf.h> | ||
26 | 27 | ||
27 | #undef LUAI_THROW | 28 | #undef LUAI_THROW |
28 | #undef LUAI_TRY | 29 | #undef LUAI_TRY |
@@ -40,9 +41,6 @@ | |||
40 | #define luai_jmpbuf jmp_buf | 41 | #define luai_jmpbuf jmp_buf |
41 | 42 | ||
42 | extern char curpath[MAX_PATH]; | 43 | extern char curpath[MAX_PATH]; |
43 | void* dlmalloc(size_t bytes); | ||
44 | void *dlrealloc(void *ptr, size_t size); | ||
45 | void dlfree(void *ptr); | ||
46 | struct tm *gmtime(const time_t *timep); | 44 | struct tm *gmtime(const time_t *timep); |
47 | long strtol(const char *nptr, char **endptr, int base); | 45 | long strtol(const char *nptr, char **endptr, int base); |
48 | unsigned long strtoul(const char *str, char **endptr, int base); | 46 | unsigned long strtoul(const char *str, char **endptr, int base); |
@@ -54,8 +52,9 @@ long lpow(long x, long y); | |||
54 | #define pow lpow | 52 | #define pow lpow |
55 | 53 | ||
56 | /* Simple substitutions */ | 54 | /* Simple substitutions */ |
57 | #define realloc dlrealloc | 55 | #define malloc tlsf_malloc |
58 | #define free dlfree | 56 | #define realloc tlsf_realloc |
57 | #define free tlsf_free | ||
59 | #define memchr rb->memchr | 58 | #define memchr rb->memchr |
60 | #define snprintf rb->snprintf | 59 | #define snprintf rb->snprintf |
61 | #define strcat rb->strcat | 60 | #define strcat rb->strcat |