From 3fef839f7514eeeadd5b4574a533146aabc595c5 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 15 May 2007 00:36:56 +0000 Subject: [PATCH] Added call to setvbuf (disabled by default for speed) to flush the memdebug log file after every line and avoid losing the last few log entries if curl crashes. --- lib/memdebug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/memdebug.c b/lib/memdebug.c index 110169474..582387cf9 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -73,6 +73,10 @@ void curl_memdebug(const char *logname) logfile = fopen(logname, "w"); else logfile = stderr; +#ifdef MEMDEBUG_LOG_SYNC + /* Flush the log file after every line so the log isn't lost in a crash */ + setvbuf(logfile, (char *)NULL, _IOLBF, 0); +#endif } }