aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2012-07-03 11:40:16 +0200
committerThomas White <taw@physics.org>2012-07-03 11:40:16 +0200
commitac964c54628af8534b811466e68583ef6e685bd2 (patch)
tree49b52fe494858a3c77ae66e4dc8065d0d182ce7e /src
parent2ad671969e26dc1d2650c6af25ec44d53ff223ee (diff)
Use fdopen() instead of fopen()
Diffstat (limited to 'src')
-rw-r--r--src/indexamajig.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 1981908e..e9ee0f7a 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -424,12 +424,12 @@ static void process_image(const struct index_args *iargs,
exit(1);
}
- fh = fopen(outfilename, "a");
+ fh = fdopen(fd, "a");
if ( fh == NULL ) {
ERROR("Couldn't open stream '%s'.\n", outfilename);
}
write_chunk(fh, &image, hdfile, iargs->stream_flags);
- fclose(fh);
+ fflush(fh);
/* Unlock stream for other processes */
fl.l_type = F_UNLCK; /* set to unlock same region */
@@ -437,7 +437,8 @@ static void process_image(const struct index_args *iargs,
ERROR("fcntl");
exit(1);
}
- close(fd);
+
+ fclose(fh); /* close(fd) happens as well because fd was not dup'd */
/* Only free cell if found */
cell_free(image.indexed_cell);