Hi Daiki,

> On a different note, it was suggested to disable stdio buffering if
> RF_SENSITIVE is set.  I am attaching a patch for this.

Reading from a regular file in an unbuffered way can be terribly slow.
But here, fread_file reads in large chunks, therefore it's OK.

Also, in the specification of fread_file, I would add a note. Maybe like
this?

diff --git a/lib/read-file.c b/lib/read-file.c
index 36780cc..f13c528 100644
--- a/lib/read-file.c
+++ b/lib/read-file.c
@@ -43,8 +43,11 @@
    *LENGTH.  On errors, *LENGTH is undefined, errno preserves the
    values set by system functions (if any), and NULL is returned.
 
-   If the RF_SENSITIVE flag is set in FLAGS, the memory buffer
-   internally allocated will be cleared upon failure.  */
+   If the RF_SENSITIVE flag is set in FLAGS:
+     - You should control the buffering of STREAM using 'setvbuf'.  Either
+       clear the buffer of STREAM after closing it, or disable buffering of
+       STREAM before calling this function.
+     - The memory buffer internally allocated will be cleared upon failure.  */
 char *
 fread_file (FILE *stream, int flags, size_t *length)
 {


Reply via email to