acb0917556
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30264 a1c6a512-1295-4272-9138-f99709370657
16 lines
351 B
C
16 lines
351 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;
|
|
}
|