--- ray/src/common/portio.c 2016/08/18 00:52:48 2.19 +++ ray/src/common/portio.c 2019/07/05 03:04:22 2.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: portio.c,v 2.19 2016/08/18 00:52:48 greg Exp $"; +static const char RCSid[] = "$Id: portio.c,v 2.21 2019/07/05 03:04:22 greg Exp $"; #endif /* * Portable i/o for binary files @@ -71,11 +71,12 @@ putbinary( /* fwrite() replacement for small objects const char *s = (const char *)p; int nbytes = elsiz*nel; - if (nbytes > 512) + if (nbytes > 256) return(fwrite(p, elsiz, nel, fp)); while (nbytes-- > 0) - putc(*s++, fp); + if (putc(*s++, fp) == EOF) + return((elsiz*nel - nbytes)/elsiz); return(nel); } @@ -152,7 +153,7 @@ getbinary( /* fread() replacement for small objects int nbytes = elsiz*nel; int c; - if (nbytes > 512) + if (nbytes > 256) return(fread(p, elsiz, nel, fp)); while (nbytes-- > 0) {