diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-04-17 16:10:28 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-04-17 16:10:28 -0400 |
commit | 74fa4aac12d0d5a04ed411f2b3240f235a4475a1 (patch) | |
tree | 1029fd927f96b1212ec6aa3d2179c92636d8ba74 /src | |
parent | 086542fb5bc88f590547147365630b9a44df223b (diff) | |
download | musl-74fa4aac12d0d5a04ed411f2b3240f235a4475a1.zip musl-74fa4aac12d0d5a04ed411f2b3240f235a4475a1.tar.gz musl-74fa4aac12d0d5a04ed411f2b3240f235a4475a1.tar.bz2 |
combine two calls to memset in fmemopen
this idea came up when I thought we might need to zero the UNGET
portion of buf as well, but it seems like a useful improvement even
when that turned out not to be necessary.
Diffstat (limited to 'src')
-rw-r--r-- | src/stdio/fmemopen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 5685092..5afd85c 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,7 +96,7 @@ 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; @@ -106,7 +107,6 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) memset(buf, 0, size); } - memset(&f->c, 0, sizeof f->c); f->c.buf = buf; f->c.size = size; f->c.mode = *mode; |