forked from len0rd/rockbox
Use CACHEALIGN_SIZE in codec_malloc for optimal alignment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29838 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f79769c541
commit
b452fa061d
1 changed files with 4 additions and 1 deletions
|
@ -35,6 +35,7 @@ static unsigned char* mallocbuf;
|
||||||
|
|
||||||
int codec_init(void)
|
int codec_init(void)
|
||||||
{
|
{
|
||||||
|
/* codec_get_buffer() aligns the resulting point to CACHEALIGN_SIZE. */
|
||||||
mem_ptr = 0;
|
mem_ptr = 0;
|
||||||
mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
|
mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
|
||||||
|
|
||||||
|
@ -60,7 +61,9 @@ void* codec_malloc(size_t size)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
x=&mallocbuf[mem_ptr];
|
x=&mallocbuf[mem_ptr];
|
||||||
mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */
|
|
||||||
|
/* Keep memory aligned to CACHEALIGN_SIZE. */
|
||||||
|
mem_ptr += (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1);
|
||||||
|
|
||||||
return(x);
|
return(x);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue