Comment the my_tmpfile_with_len() function.
authorColin Leroy <colin@colino.net>
Wed, 10 Oct 2018 08:09:11 +0000 (10:09 +0200)
committerColin Leroy <colin@colino.net>
Wed, 10 Oct 2018 08:09:11 +0000 (10:09 +0200)
src/common/file-utils.c

index 0d6d227d4f0147f4536a5385a9ff81d4937673ef..e4d7a5ea51a1a7cab9b447e41f0f31a143686b3b 100644 (file)
@@ -827,6 +827,19 @@ FILE *my_tmpfile(void)
        return tmpfile();
 }
 
+/* Returns a memory-backed FILE pointer to avoid file I/O
+ * where unnecessary. The "file" size is passed in the len
+ * parameter and is fixed: it's up to the caller to pass a
+ * large enough length to write to the FILE pointer. If the
+ * precise length isn't known, it is possible to ask for more.
+ * 
+ * In this case, once writing to the pointer is done, the 
+ * caller is responsible to call ftruncate(fileno(fp), ftell(fp))
+ * to make sure re-reading the stream will return EOF at the
+ * end of what we wrote. 
+ * Otherwise, re-reading the stream will return uninitialized
+ * memory at the end of the stream.
+ */
 FILE *my_tmpfile_with_len(size_t len)
 {
 #if HAVE_FMEMOPEN