1 // 2 // _freebuf.cpp 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // Defines __acrt_stdio_free_buffer(), which releaes a buffer from a stream. 7 // 8 #include <corecrt_internal_stdio.h> 9 10 11 12 // Releases a buffer from a stream. If the stream is buffered and the buffer 13 // was allocated by the CRT, the space is freed. If the buffer was provided by 14 // the user, it is not freed (since we do not know how to free it). __acrt_stdio_free_buffer_nolock(FILE * const public_stream)15extern "C" void __cdecl __acrt_stdio_free_buffer_nolock(FILE* const public_stream) 16 { 17 _ASSERTE(public_stream != nullptr); 18 19 __crt_stdio_stream const stream(public_stream); 20 21 if (!stream.is_in_use()) 22 return; 23 24 if (!stream.has_crt_buffer()) 25 return; 26 27 _free_crt(stream->_base); 28 29 stream.unset_flags(_IOBUFFER_CRT | _IOBUFFER_SETVBUF); 30 stream->_base = nullptr; 31 stream->_ptr = nullptr; 32 stream->_cnt = 0; 33 } 34