summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2013-08-22 12:12:47 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2013-08-26 09:42:47 +0200
commita2a2e14e0d400e1c82b4d02c4399602488578dc6 (patch)
tree87e63279ef95ce06315b492d85a009b58f3782b2 /lib
parentb2e80edd1671833dc80eb0c5334cb6a2c58808e0 (diff)
downloadrockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.tar.gz
rockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.tar.bz2
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 'lib')
-rw-r--r--lib/tlsf/src/tlsf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/tlsf/src/tlsf.c b/lib/tlsf/src/tlsf.c
index 87f8d262ee..6866f0c9b0 100644
--- a/lib/tlsf/src/tlsf.c
+++ b/lib/tlsf/src/tlsf.c
@@ -395,6 +395,14 @@ static __inline__ bhdr_t *FIND_SUITABLE_BLOCK(tlsf_t * _tlsf, int *_fl, int *_sl
set_bit (_fl, &_tlsf -> fl_bitmap); \
} while(0)
+#if defined(ROCKBOX)
+void * __attribute__((weak)) get_new_area(size_t * size)
+{
+ (void)size;
+ return ((void *) ~0);
+}
+#endif
+
#if USE_SBRK || USE_MMAP
static __inline__ void *get_new_area(size_t * size)
{
@@ -615,7 +623,7 @@ void *tlsf_malloc(size_t size)
/******************************************************************/
void *ret;
-#if USE_MMAP || USE_SBRK
+#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
if (!mp) {
size_t area_size;
void *area;
@@ -657,7 +665,7 @@ void *tlsf_realloc(void *ptr, size_t size)
/******************************************************************/
void *ret;
-#if USE_MMAP || USE_SBRK
+#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
if (!mp) {
return tlsf_malloc(size);
}
@@ -705,7 +713,7 @@ void *malloc_ex(size_t size, void *mem_pool)
so they are not longer valid when the function fails */
b = FIND_SUITABLE_BLOCK(tlsf, &fl, &sl);
-#if USE_MMAP || USE_SBRK
+#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
if (!b) {
size_t area_size;
void *area;