mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
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.
This commit is contained in:
parent
086542fb5b
commit
74fa4aac12
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue