diff options
| author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-08 16:12:28 +0000 |
|---|---|---|
| committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-08 16:12:28 +0000 |
| commit | ca4771b40c7c8354eea4db5053a5f15755c63d10 (patch) | |
| tree | af26d45624a97b3648b885c71f74f24fd318283b | |
| parent | 551db40abb4c9c1664c291bc431c4a3f55e530c7 (diff) | |
| download | rockbox-ca4771b40c7c8354eea4db5053a5f15755c63d10.zip rockbox-ca4771b40c7c8354eea4db5053a5f15755c63d10.tar.gz rockbox-ca4771b40c7c8354eea4db5053a5f15755c63d10.tar.bz2 rockbox-ca4771b40c7c8354eea4db5053a5f15755c63d10.tar.xz | |
Thanks to the changes in prep_bufdata, bufgetdata can be simplified a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15537 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/buffering.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index c59fc52..e55e81d 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -996,6 +996,7 @@ static struct memory_handle *prep_bufdata(int handle_id, size_t *size, /* If more than the size of the guardbuf is requested and this is a * bufgetdata, limit to guard_bufsize over the end of the buffer */ *size = MIN(*size, buffer_len - h->ridx + GUARD_BUFSIZE); + /* this ensures *size <= buffer_len - h->ridx + GUARD_BUFSIZE */ } if (h->filerem > 0 && avail < *size) @@ -1068,9 +1069,10 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data) { /* the data wraps around the end of the buffer : use the guard buffer to provide the requested amount of data. */ - size_t copy_n = MIN(h->ridx + size - buffer_len, GUARD_BUFSIZE); + size_t copy_n = h->ridx + size - buffer_len; + /* prep_bufdata ensures size <= buffer_len - h->ridx + GUARD_BUFSIZE, + so copy_n <= GUARD_BUFSIZE */ memcpy(guard_buffer, (unsigned char *)buffer, copy_n); - size = buffer_len - h->ridx + copy_n; } *data = &buffer[h->ridx]; |