ReactOS 0.4.16-dev-1078-g21d3e29
_sftbuf.cpp File Reference
Include dependency graph for _sftbuf.cpp:

Go to the source code of this file.

Functions

bool __acrt_should_use_temporary_buffer (FILE *const stream)
 
bool __cdecl __acrt_stdio_begin_temporary_buffering_nolock (FILE *const public_stream)
 
void __cdecl __acrt_stdio_end_temporary_buffering_nolock (bool const flag, FILE *const public_stream, __crt_cached_ptd_host &ptd)
 

Variables

void__acrt_stdout_buffer = nullptr
 
void__acrt_stderr_buffer = nullptr
 

Function Documentation

◆ __acrt_should_use_temporary_buffer()

bool __acrt_should_use_temporary_buffer ( FILE *const  stream)

Definition at line 34 of file _sftbuf.cpp.

35{
36 if (stream == stderr)
37 {
38 return true;
39 }
40
42 {
43 return true;
44 }
45
46 return false;
47}
#define stdout
Definition: stdio.h:99
_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE *_File)
#define stderr
Definition: stdio.h:100
_Check_return_ _CRTIMP int __cdecl _isatty(_In_ int _FileHandle)
Definition: parse.h:23

Referenced by __acrt_stdio_begin_temporary_buffering_nolock(), __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(), and common_flush_and_write_nolock().

◆ __acrt_stdio_begin_temporary_buffering_nolock()

bool __cdecl __acrt_stdio_begin_temporary_buffering_nolock ( FILE *const  public_stream)

Definition at line 54 of file _sftbuf.cpp.

57{
58 _ASSERTE(public_stream != nullptr);
59
60 __crt_stdio_stream const stream(public_stream);
61
62 if (!__acrt_should_use_temporary_buffer(stream.public_stream()))
63 {
64 return false;
65 }
66
67 void** buffer;
68 if (stream.public_stream() == stdout)
69 {
71 }
72 else if (stream.public_stream() == stderr)
73 {
75 }
76 else
77 {
78 return false;
79 }
80
81 #ifndef CRTDLL
82 _cflush++; // Force library pre-termination procedure to run
83 #endif
84
85 // Make sure the stream is not already buffered:
86 if (stream.has_any_buffer())
87 {
88 return false;
89 }
90
92 if (*buffer == nullptr)
93 {
94 *buffer = _malloc_crt_t(char, _INTERNAL_BUFSIZ).detach();
95 }
96
97 if (*buffer == nullptr)
98 {
99 // If we failed to allocate a buffer, use the small character buffer:
100 stream->_base = reinterpret_cast<char*>(&stream->_charbuf);
101 stream->_ptr = reinterpret_cast<char*>(&stream->_charbuf);
102 stream->_cnt = 2;
103 stream->_bufsiz = 2;
104 return true;
105 }
106
107 // Otherwise, we have a new buffer, so set it up for use:
108 stream->_base = reinterpret_cast<char*>(*buffer);
109 stream->_ptr = reinterpret_cast<char*>(*buffer);
110 stream->_cnt = _INTERNAL_BUFSIZ;
111 stream->_bufsiz = _INTERNAL_BUFSIZ;
112 return true;
113}
int _cflush
Definition: _file.cpp:53
bool __acrt_should_use_temporary_buffer(FILE *const stream)
Definition: _sftbuf.cpp:34
void * __acrt_stdout_buffer
Definition: _sftbuf.cpp:26
void * __acrt_stderr_buffer
Definition: _sftbuf.cpp:27
#define _INTERNAL_BUFSIZ
@ _IOBUFFER_USER
@ _IOBUFFER_STBUF
#define _ASSERTE(expr)
Definition: crtdbg.h:114
GLuint buffer
Definition: glext.h:5915

Referenced by __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0().

◆ __acrt_stdio_end_temporary_buffering_nolock()

void __cdecl __acrt_stdio_end_temporary_buffering_nolock ( bool const  flag,
FILE *const  public_stream,
__crt_cached_ptd_host &  ptd 
)

Definition at line 120 of file _sftbuf.cpp.

125{
126 __crt_stdio_stream const stream(public_stream);
127
128 if (!flag)
129 return;
130
131 if (stream.has_temporary_buffer())
132 {
133 // Flush the stream and tear down temporary buffering:
134 __acrt_stdio_flush_nolock(stream.public_stream(), ptd);
136 stream->_bufsiz = 0;
137 stream->_base = nullptr;
138 stream->_ptr = nullptr;
139 }
140
141 // Note: If we expand the functionality of the _IOBUFFER_STBUF bit to
142 // include other streams, we may want to clear that bit here under an
143 // 'else' clause (i.e., clear bit in the case that we leave the buffer
144 // permanently assigned. Given our current use of the bit, the extra
145 // code is not needed.
146}
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
int __cdecl __acrt_stdio_flush_nolock(FILE *const public_stream, __crt_cached_ptd_host &ptd)
Definition: fflush.cpp:222
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52

Referenced by __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0().

Variable Documentation

◆ __acrt_stderr_buffer

void* __acrt_stderr_buffer = nullptr

◆ __acrt_stdout_buffer

void* __acrt_stdout_buffer = nullptr