3 #if defined(CPU_ARM) || defined(CPU_COLDFIRE)
5 extern jmp_buf rb_jump_buf
;
10 void ogg_malloc_init(void)
12 mallocbuf
= ci
->codec_get_buffer(&bufsize
);
13 tmp_ptr
= bufsize
& ~3;
17 void *ogg_malloc(size_t size
)
21 size
= (size
+ 3) & ~3;
23 if (mem_ptr
+ size
> tmp_ptr
)
24 #if defined(CPU_ARM) || defined(CPU_COLDFIRE)
25 longjmp(rb_jump_buf
, 1);
30 x
= &mallocbuf
[mem_ptr
];
31 mem_ptr
+= size
; /* Keep memory 32-bit aligned */
36 void *ogg_tmpmalloc(size_t size
)
38 size
= (size
+ 3) & ~3;
40 if (mem_ptr
+ size
> tmp_ptr
)
44 return &mallocbuf
[tmp_ptr
];
47 void *ogg_calloc(size_t nmemb
, size_t size
)
50 x
= ogg_malloc(nmemb
* size
);
53 ci
->memset(x
, 0, nmemb
* size
);
57 void *ogg_tmpcalloc(size_t nmemb
, size_t size
)
60 x
= ogg_tmpmalloc(nmemb
* size
);
63 ci
->memset(x
, 0, nmemb
* size
);
67 void *ogg_realloc(void *ptr
, size_t size
)
75 long ogg_tmpmalloc_pos(void)
80 void ogg_tmpmalloc_free(long pos
)
85 /* Allocate IRAM buffer */
86 static unsigned char iram_buff
[IRAM_IBSS_SIZE
] IBSS_ATTR
__attribute__ ((aligned (16)));
87 static size_t iram_remain
;
89 void iram_malloc_init(void){
90 iram_remain
=IRAM_IBSS_SIZE
;
93 void *iram_malloc(size_t size
){
96 /* always ensure 16-byte aligned */
98 size
=(size
-(size
&0x0f))+16;
103 x
= &iram_buff
[IRAM_IBSS_SIZE
-iram_remain
];