diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2009-03-08 12:48:58 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2009-03-08 12:48:58 +0000 |
commit | f4515c3082dd413017ae06c25d7e85b1dcee30bf (patch) | |
tree | 1154b2fd5049aa42a1fdd2047effd39e9da1ccaa /apps/codecs/libtremor/oggmalloc.c | |
parent | 3f69bb2b1d00ccc54e2097fd9da750fcd2f7e11b (diff) | |
download | rockbox-f4515c3082dd413017ae06c25d7e85b1dcee30bf.tar.gz rockbox-f4515c3082dd413017ae06c25d7e85b1dcee30bf.zip |
Add setjmp/longjmp for ARM and ColdFire to the codec lib, and use it in the Vorbis codec to better handle out of memory conditions (to exit rather than crash; the AAC codec could use it too). setjmp/longjmp comes from newlib 1.17.0 with a few minor changes (combine parts of some files, remove support for some architectures, change some ifdef's).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20235 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libtremor/oggmalloc.c')
-rw-r--r-- | apps/codecs/libtremor/oggmalloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/apps/codecs/libtremor/oggmalloc.c b/apps/codecs/libtremor/oggmalloc.c index ca917ff397..4aa2760629 100644 --- a/apps/codecs/libtremor/oggmalloc.c +++ b/apps/codecs/libtremor/oggmalloc.c | |||
@@ -1,5 +1,10 @@ | |||
1 | #include "os_types.h" | 1 | #include "os_types.h" |
2 | 2 | ||
3 | #if defined(CPU_ARM) || defined(CPU_COLDFIRE) | ||
4 | #include <setjmp.h> | ||
5 | extern jmp_buf rb_jump_buf; | ||
6 | #endif | ||
7 | |||
3 | static size_t tmp_ptr; | 8 | static size_t tmp_ptr; |
4 | 9 | ||
5 | void ogg_malloc_init(void) | 10 | void ogg_malloc_init(void) |
@@ -16,7 +21,11 @@ void *ogg_malloc(size_t size) | |||
16 | size = (size + 3) & ~3; | 21 | size = (size + 3) & ~3; |
17 | 22 | ||
18 | if (mem_ptr + size > tmp_ptr) | 23 | if (mem_ptr + size > tmp_ptr) |
24 | #if defined(CPU_ARM) || defined(CPU_COLDFIRE) | ||
25 | longjmp(rb_jump_buf, 1); | ||
26 | #else | ||
19 | return NULL; | 27 | return NULL; |
28 | #endif | ||
20 | 29 | ||
21 | x = &mallocbuf[mem_ptr]; | 30 | x = &mallocbuf[mem_ptr]; |
22 | mem_ptr += size; /* Keep memory 32-bit aligned */ | 31 | mem_ptr += size; /* Keep memory 32-bit aligned */ |