From 767a5818741f84ebeb4a422870881c769e751c0b Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 30 Jun 2015 16:47:25 -0700 Subject: [PATCH] Inline the I/O in the long long serialization loop --- geojson.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/geojson.c b/geojson.c index 26a01d06..4091e37f 100644 --- a/geojson.c +++ b/geojson.c @@ -75,11 +75,17 @@ void serialize_long_long(FILE *out, long long n, long long *fpos, const char *fn unsigned char b = zigzag & 0x7F; if ((zigzag >> 7) != 0) { b |= 0x80; - fwrite_check(&b, sizeof(unsigned char), 1, out, fname); + if (putc(b, out) == EOF) { + fprintf(stderr, "%s: Write to temporary file failed: %s\n", fname, strerror(errno)); + exit(EXIT_FAILURE); + } *fpos += 1; zigzag >>= 7; } else { - fwrite_check(&b, sizeof(unsigned char), 1, out, fname); + if (putc(b, out) == EOF) { + fprintf(stderr, "%s: Write to temporary file failed: %s\n", fname, strerror(errno)); + exit(EXIT_FAILURE); + } *fpos += 1; break; }