add flushed fwrite in Valgrind mode

This commit is contained in:
Josh Coalson
2002-12-28 07:04:49 +00:00
parent 8b9a477a8c
commit f91251d1d6
13 changed files with 158 additions and 55 deletions

View File

@@ -28,6 +28,18 @@
#endif
#define min(a,b) ((a)<(b)?(a):(b))
#ifdef FLAC__VALGRIND_TESTING
static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t ret = fwrite(ptr, size, nmemb, stream);
if(!ferror(stream))
fflush(stream);
return ret;
}
#else
#define local__fwrite fwrite
#endif
typedef struct {
FILE *file;
} encoder_client_struct;
@@ -38,7 +50,7 @@ static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const FLAC__Stream
(void)encoder, (void)samples, (void)current_frame;
if(fwrite(buffer, 1, bytes, ecd->file) != bytes)
if(local__fwrite(buffer, 1, bytes, ecd->file) != bytes)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
else
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;