32 size_t available = mem->
size - mem->
pos;
34 if (size > available) {
37 memcpy(buf, mem->
buffer + mem->
pos,
sizeof(
char) * size);
43 static int writefn(
void *handler,
const char *buf,
int size) {
45 size_t available = mem->
size - mem->
pos;
47 if (size > available) {
50 memcpy(mem->
buffer + mem->
pos, buf,
sizeof(
char) * size);
56 static fpos_t
seekfn(
void *handler, fpos_t offset,
int whence) {
70 if (offset >= 0 || (
size_t)(-offset) <= mem->
pos) {
71 pos = mem->
pos + (size_t)offset;
77 case SEEK_END: pos = mem->
size + (size_t)offset;
break;
81 if (pos > mem->
size) {
99 memset(mem, 0,
sizeof(
fmem_t));
static fpos_t seekfn(void *handler, fpos_t offset, int whence)
static int readfn(void *handler, char *buf, int size)
static int writefn(void *handler, const char *buf, int size)
FILE * fmemopen(void *buf, size_t size, const char *mode)
A BSD port of the fmemopen Linux method using funopen.
static int closefn(void *handler)