소스 검색

minor cleanup in fopencookie

assign entire struct rather than member-at-a-time. don't repeat buffer
sizes; always use sizeof to ensure consistency.
Rich Felker 7 년 전
부모
커밋
4245a233c1
1개의 변경된 파일2개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 5
      src/stdio/fopencookie.c

+ 2 - 5
src/stdio/fopencookie.c

@@ -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. */