summaryrefslogtreecommitdiffstats
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-03-13 11:56:51 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-03-13 11:56:51 +0000
commit7cac18f94b512d8541456c2a68f7bfb05a5bd6e8 (patch)
tree1bf4092efef05374c5bbe2376f2d7f835435463b /apps/buffering.c
parente86a7fb77d22cdd593162e91d57012f4ae61cc81 (diff)
downloadrockbox-7cac18f94b512d8541456c2a68f7bfb05a5bd6e8.tar.gz
rockbox-7cac18f94b512d8541456c2a68f7bfb05a5bd6e8.tar.bz2
rockbox-7cac18f94b512d8541456c2a68f7bfb05a5bd6e8.zip
Use ringbuf_add in buffering when incrementing for initial allocation of non-wrapping data. The result of the shortcut would have been wrong if the handle used space exactly to the end of the buffer since buf_widx wouldn't have been properly wrapped to index 0.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29578 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 2949a81a87..0cd81df93a 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -950,8 +950,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
h->type = type;
strlcpy(h->path, file, MAX_PATH);
- buf_widx += sizeof(struct mp3entry); /* safe because the handle
- can't wrap */
+ buf_widx = ringbuf_add(buf_widx, sizeof(struct mp3entry));
+
h->filerem = sizeof(struct mp3entry);
/* Inform the buffering thread that we added a handle */
@@ -1037,8 +1037,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
} else {
h->filesize = rc;
h->available = rc;
- h->widx = buf_widx + rc; /* safe because the data doesn't wrap */
- buf_widx += rc; /* safe too */
+ buf_widx = ringbuf_add(buf_widx, rc);
+ h->widx = buf_widx;
}
}
else
@@ -1107,12 +1107,11 @@ int bufalloc(const void *src, size_t size, enum data_type type)
h->filesize = size;
h->offset = 0;
h->ridx = buf_widx;
- h->widx = buf_widx + size; /* safe because the data doesn't wrap */
h->data = buf_widx;
+ buf_widx = ringbuf_add(buf_widx, size);
+ h->widx = buf_widx;
h->available = size;
h->type = type;
-
- buf_widx += size; /* safe too */
}
mutex_unlock(&llist_mutex);