2 #include "../lib/tlsf/src/tlsf.h"
4 #if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS)
6 extern jmp_buf rb_jump_buf
;
7 #define LONGJMP(x) longjmp(rb_jump_buf, x)
8 #elif defined(SIMULATOR)
9 #define LONGJMP(x) do { DEBUGF("Vorbis: allocation failed!\n"); return NULL; } while (false)
11 #define LONGJMP(x) return NULL
14 void ogg_malloc_init(void)
17 void* buf
= ci
->codec_get_buffer(&bufsize
);
18 init_memory_pool(bufsize
, buf
);
21 void ogg_malloc_destroy()
24 void* buf
= ci
->codec_get_buffer(&bufsize
);
25 destroy_memory_pool(buf
);
28 void *ogg_malloc(size_t size
)
30 void* x
= tlsf_malloc(size
);
38 void *ogg_calloc(size_t nmemb
, size_t size
)
40 void *x
= tlsf_calloc(nmemb
, size
);
48 void *ogg_realloc(void *ptr
, size_t size
)
50 void *x
= tlsf_realloc(ptr
, size
);
58 void ogg_free(void* ptr
)
63 /* Allocate IRAM buffer */
64 static unsigned char iram_buff
[IRAM_IBSS_SIZE
] IBSS_ATTR
__attribute__ ((aligned (16)));
65 static size_t iram_remain
;
67 void iram_malloc_init(void){
68 iram_remain
=IRAM_IBSS_SIZE
;
71 void *iram_malloc(size_t size
){
74 /* always ensure 16-byte aligned */
76 size
=(size
-(size
&0x0f))+16;
81 x
= &iram_buff
[IRAM_IBSS_SIZE
-iram_remain
];