summaryrefslogtreecommitdiff
path: root/src/stdio/fmemopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/fmemopen.c')
-rw-r--r--src/stdio/fmemopen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c
index 5685092e..343e3e3f 100644
--- a/src/stdio/fmemopen.c
+++ b/src/stdio/fmemopen.c
@@ -2,6 +2,7 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <stddef.h>
#include <inttypes.h>
#include "libc.h"
@@ -95,18 +96,17 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode)
f = malloc(sizeof *f + (buf?0:size));
if (!f) return 0;
- memset(&f->f, 0, sizeof f->f);
+ memset(f, 0, offsetof(struct mem_FILE, buf));
f->f.cookie = &f->c;
f->f.fd = -1;
f->f.lbf = EOF;
f->f.buf = f->buf + UNGET;
f->f.buf_size = sizeof f->buf - UNGET;
if (!buf) {
- buf = f->buf2;;
+ buf = f->buf2;
memset(buf, 0, size);
}
- memset(&f->c, 0, sizeof f->c);
f->c.buf = buf;
f->c.size = size;
f->c.mode = *mode;