f40bfc9267
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97 Reviewed-on: http://gerrit.rockbox.org/137 Reviewed-by: Nils Wallménius <nils@rockbox.org> Tested-by: Nils Wallménius <nils@rockbox.org>
16 lines
335 B
C
16 lines
335 B
C
|
|
/* Memory buffer reader, simulates file read
|
|
@ gama
|
|
*/
|
|
|
|
#include "mbreader.h"
|
|
|
|
int mbread(struct mbreader_t *md, void *buf, size_t n)
|
|
{
|
|
if (!md) return -1;
|
|
size_t read_bytes = (md->offset+n) > md->size ?
|
|
md->size-md->offset : n;
|
|
memcpy(buf,md->ptr + md->offset,read_bytes);
|
|
md->offset += read_bytes;
|
|
return read_bytes;
|
|
}
|