ReactOS 0.4.16-dev-927-g467dec4
fclose.cpp File Reference
Include dependency graph for fclose.cpp:

Go to the source code of this file.

Functions

static int __cdecl _fclose_nolock_internal (FILE *const public_stream, __crt_cached_ptd_host &ptd)
 
int __cdecl _fclose_nolock (FILE *const public_stream)
 
static int __cdecl _fclose_internal (FILE *const public_stream, __crt_cached_ptd_host &ptd)
 
int __cdecl fclose (FILE *const public_stream)
 

Function Documentation

◆ _fclose_internal()

static int __cdecl _fclose_internal ( FILE *const  public_stream,
__crt_cached_ptd_host &  ptd 
)
static

Definition at line 52 of file fclose.cpp.

53{
54 __crt_stdio_stream const stream(public_stream);
55
57
58 // If the stream is backed by a string, it requires no synchronization,
59 // flushing, etc., so we can simply free it, which resets all of its
60 // data to the defaults.
61 if (stream.is_string_backed())
62 {
64 return EOF;
65 }
66
67 int return_value = 0;
68
69 _lock_file(stream.public_stream());
70 __try
71 {
72 return_value = _fclose_nolock_internal(stream.public_stream(), ptd);
73 }
75 {
76 _unlock_file(stream.public_stream());
77 }
79
80 return return_value;
81}
#define EINVAL
Definition: acclib.h:90
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)
void __cdecl __acrt_stdio_free_stream(__crt_stdio_stream _Stream)
Definition: stream.cpp:97
_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
static int __cdecl _fclose_nolock_internal(FILE *const public_stream, __crt_cached_ptd_host &ptd)
Definition: fclose.cpp:17
#define EOF
Definition: stdio.h:24
_CRTIMP void __cdecl _unlock_file(_Inout_ FILE *_File)
_CRTIMP void __cdecl _lock_file(_Inout_ FILE *_File)
#define __try
Definition: pseh2_64.h:188
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
Definition: parse.h:23

Referenced by fclose().

◆ _fclose_nolock()

int __cdecl _fclose_nolock ( FILE *const  public_stream)

Definition at line 46 of file fclose.cpp.

47{
48 __crt_cached_ptd_host ptd;
49 return _fclose_nolock_internal(public_stream, ptd);
50}

◆ _fclose_nolock_internal()

static int __cdecl _fclose_nolock_internal ( FILE *const  public_stream,
__crt_cached_ptd_host &  ptd 
)
static

Definition at line 17 of file fclose.cpp.

18{
19 __crt_stdio_stream const stream(public_stream);
20
22
23 int result = EOF;
24
25 if (stream.is_in_use())
26 {
27 result = __acrt_stdio_flush_nolock(stream.public_stream(), ptd);
29
30 if (_close_internal(_fileno(stream.public_stream()), ptd) < 0)
31 {
32 result = EOF;
33 }
34 else if (stream->_tmpfname != nullptr)
35 {
36 _free_crt(stream->_tmpfname);
37 stream->_tmpfname = nullptr;
38 }
39 }
40
42
43 return result;
44}
void __cdecl __acrt_stdio_free_buffer_nolock(FILE *const public_stream)
Definition: _freebuf.cpp:15
_Check_return_opt_ int __cdecl _close_internal(_In_ int _FileHandle, _Inout_ __crt_cached_ptd_host &_Ptd)
int __cdecl __acrt_stdio_flush_nolock(FILE *const public_stream, __crt_cached_ptd_host &ptd)
Definition: fflush.cpp:222
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE *_File)
#define _free_crt

Referenced by _fclose_internal(), and _fclose_nolock().

◆ fclose()

int __cdecl fclose ( FILE *const  public_stream)

Definition at line 83 of file fclose.cpp.

84{
85 __crt_cached_ptd_host ptd;
86 return _fclose_internal(public_stream, ptd);
87}
static int __cdecl _fclose_internal(FILE *const public_stream, __crt_cached_ptd_host &ptd)
Definition: fclose.cpp:52