From: Daniel Stenberg Date: Fri, 4 Jul 2003 17:16:34 +0000 (+0000) Subject: remove the usage of setvbuf() and use fflush() instead if no buffering should X-Git-Tag: curl-7_10_6~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=269d491b6a71b5c3107681d95dcfa7b2baa4b538;p=curl remove the usage of setvbuf() and use fflush() instead if no buffering should be done on the output --- diff --git a/src/main.c b/src/main.c index 6b84f3f33..a40bc8be7 100644 --- a/src/main.c +++ b/src/main.c @@ -2063,6 +2063,7 @@ struct OutStruct { int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { + int rc; struct OutStruct *out=(struct OutStruct *)stream; struct Configurable *config = out->config; if(out && !out->stream) { @@ -2070,12 +2071,6 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) out->stream=fopen(out->filename, "wb"); if(!out->stream) return -1; /* failure */ - if(config->nobuffer) { - /* disable output buffering */ -#ifdef HAVE_SETVBUF - setvbuf(out->stream, NULL, _IONBF, 0); -#endif - } } if(config->recvpersecond) { @@ -2098,7 +2093,13 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) config->lastrecvtime = now; } - return fwrite(buffer, size, nmemb, out->stream); + rc = fwrite(buffer, size, nmemb, out->stream); + + if(config->nobuffer) + /* disable output buffering */ + fflush(out->stream); + + return rc; } struct InStruct {