int setvbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf, int mode, size_t size )
{
+ _PDCLIB_lockfile( stream );
switch ( mode )
{
case _IONBF:
/* PDCLib only supports buffers up to INT_MAX in size. A size
of zero doesn't make sense.
*/
+ _PDCLIB_funlockfile( stream );
return -1;
}
if ( buf == NULL )
if ( ( buf = (char *) malloc( size ) ) == NULL )
{
/* Out of memory error. */
+ _PDCLIB_funlockfile( stream );
return -1;
}
/* This buffer must be free()d on fclose() */
break;
default:
/* If mode is something else than _IOFBF, _IOLBF or _IONBF -> exit */
+ _PDCLIB_funlockfile( stream );
return -1;
}
/* Deleting current buffer mode */
stream->status &= ~( _IOFBF | _IOLBF | _IONBF );
/* Set user-defined mode */
stream->status |= mode;
+ _PDCLIB_funlockfile( stream );
return 0;
}