minor cleanup in fopencookie
authorRich Felker <dalias@aerifal.cx>
Wed, 18 Apr 2018 18:46:05 +0000 (14:46 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 18 Apr 2018 18:46:05 +0000 (14:46 -0400)
assign entire struct rather than member-at-a-time. don't repeat buffer
sizes; always use sizeof to ensure consistency.

src/stdio/fopencookie.c

index 2f46dd5347fc9b8b8479b52028613ee8e80616ad..da042fe8adc37c7468aace6a29ae1c0b3796cc81 100644 (file)
@@ -116,15 +116,12 @@ FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t iofuncs)
 
        /* Set up our fcookie */
        f->fc.cookie = cookie;
-       f->fc.iofuncs.read = iofuncs.read;
-       f->fc.iofuncs.write = iofuncs.write;
-       f->fc.iofuncs.seek = iofuncs.seek;
-       f->fc.iofuncs.close = iofuncs.close;
+       f->fc.iofuncs = iofuncs;
 
        f->f.fd = -1;
        f->f.cookie = &f->fc;
        f->f.buf = f->buf + UNGET;
-       f->f.buf_size = BUFSIZ;
+       f->f.buf_size = sizeof f->buf - UNGET;
        f->f.lbf = EOF;
 
        /* Initialize op ptrs. No problem if some are unneeded. */