From e69866192e467d082d4f47b94e3cf80a5cbd42df Mon Sep 17 00:00:00 2001 From: gevaerts Date: Tue, 21 Jun 2011 22:04:17 +0000 Subject: [PATCH] Workaround/fix (I'm not sure!) for buffer_alloc() returning unaligned addresses in case other parts of the code increase audiobuf behind buffer.c's back. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30049 a1c6a512-1295-4272-9138-f99709370657 --- firmware/buffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/firmware/buffer.c b/firmware/buffer.c index a1a9b0556..c317cec92 100644 --- a/firmware/buffer.c +++ b/firmware/buffer.c @@ -61,7 +61,7 @@ void buffer_init(void) void *buffer_alloc(size_t size) { - void *retval = audiobuf; + void *retval; #ifdef BUFFER_ALLOC_DEBUG struct buffer_start_marker *start; struct buffer_end_marker *end; @@ -70,6 +70,11 @@ void *buffer_alloc(size_t size) /* 32-bit aligned */ size = (size + 3) & ~3; + /* Other code touches audiobuf. Make sure it stays aligned */ + audiobuf = (void *)(((unsigned long)audiobuf + 3) & ~3); + + retval = audiobuf; + #ifdef BUFFER_ALLOC_DEBUG retval +=sizeof(struct buffer_start_marker); if(size>0) -- 2.11.4.GIT