summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2010-09-26 12:27:38 +0000
committerFrank Gevaerts <frank@gevaerts.be>2010-09-26 12:27:38 +0000
commit74dbb3c27b4dfd40bc15886d4b198e8326d9ecf5 (patch)
treec7a0124ee7189249339f876ca5949121e028baf0 /firmware
parent8ff4f1aec9f19613e4f67d2e22ae96bec7657292 (diff)
downloadrockbox-74dbb3c27b4dfd40bc15886d4b198e8326d9ecf5.tar.gz
rockbox-74dbb3c27b4dfd40bc15886d4b198e8326d9ecf5.tar.bz2
rockbox-74dbb3c27b4dfd40bc15886d4b198e8326d9ecf5.zip
If BUFFER_ALLOC_DEBUG is defined, make buffer_alloc() not actually allocate anything if size==0, so code that uses buffer_alloc(0) to find out what address it would get keeps working
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28174 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/buffer.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/firmware/buffer.c b/firmware/buffer.c
index a21a882ff2..4ede24df21 100644
--- a/firmware/buffer.c
+++ b/firmware/buffer.c
@@ -72,19 +72,22 @@ void *buffer_alloc(size_t size)
#ifdef BUFFER_ALLOC_DEBUG
retval +=sizeof(struct buffer_start_marker);
- end=(struct buffer_end_marker*)(audiobuf - sizeof(struct buffer_end_marker));
- if(end->magic == BUF_MAGIC)
+ if(size>0)
{
- end->last=0;
- }
- start=(struct buffer_start_marker*)audiobuf;
- start->magic = BUF_MAGIC;
- start->buffer_size = size;
- end=(struct buffer_end_marker*)(audiobuf+sizeof(struct buffer_start_marker)+size);
- end->magic = BUF_MAGIC;
- end->last = 1;
+ end=(struct buffer_end_marker*)(audiobuf - sizeof(struct buffer_end_marker));
+ if(end->magic == BUF_MAGIC)
+ {
+ end->last=0;
+ }
+ start=(struct buffer_start_marker*)audiobuf;
+ start->magic = BUF_MAGIC;
+ start->buffer_size = size;
+ end=(struct buffer_end_marker*)(audiobuf+sizeof(struct buffer_start_marker)+size);
+ end->magic = BUF_MAGIC;
+ end->last = 1;
- audiobuf = ((unsigned char *)end) + sizeof(struct buffer_end_marker);
+ audiobuf = ((unsigned char *)end) + sizeof(struct buffer_end_marker);
+ }
logf("Alloc %x %d",(unsigned int)retval,size);
#else /* !BUFFER_ALLOC_DEBUG */