mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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:
parent
b2e80edd16
commit
a2a2e14e0d
10 changed files with 50 additions and 5173 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue