diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-05-08 19:50:39 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-05-08 19:50:39 +0000 |
commit | b452fa061d2f4e88466f9dbadc8f52425dcd2d19 (patch) | |
tree | c40c8f1c7d64f82ae95f1c8d27f234c9166e63c8 | |
parent | f79769c541eb7235b09625cb084dfdfe6069cb96 (diff) | |
download | rockbox-b452fa061d2f4e88466f9dbadc8f52425dcd2d19.tar.gz rockbox-b452fa061d2f4e88466f9dbadc8f52425dcd2d19.zip |
Use CACHEALIGN_SIZE in codec_malloc for optimal alignment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29838 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/lib/codeclib.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c index e672a78cc2..bb736ad887 100644 --- a/apps/codecs/lib/codeclib.c +++ b/apps/codecs/lib/codeclib.c | |||
@@ -35,6 +35,7 @@ static unsigned char* mallocbuf; | |||
35 | 35 | ||
36 | int codec_init(void) | 36 | int codec_init(void) |
37 | { | 37 | { |
38 | /* codec_get_buffer() aligns the resulting point to CACHEALIGN_SIZE. */ | ||
38 | mem_ptr = 0; | 39 | mem_ptr = 0; |
39 | mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize); | 40 | mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize); |
40 | 41 | ||
@@ -60,7 +61,9 @@ void* codec_malloc(size_t size) | |||
60 | return NULL; | 61 | return NULL; |
61 | 62 | ||
62 | x=&mallocbuf[mem_ptr]; | 63 | x=&mallocbuf[mem_ptr]; |
63 | mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */ | 64 | |
65 | /* Keep memory aligned to CACHEALIGN_SIZE. */ | ||
66 | mem_ptr += (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1); | ||
64 | 67 | ||
65 | return(x); | 68 | return(x); |
66 | } | 69 | } |