ReactOS
0.4.16-dev-959-g2ec3a19
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
setmaxf.cpp
Go to the documentation of this file.
1
//
2
// setmaxf.cpp
3
//
4
// Copyright (c) Microsoft Corporation. All rights reserved.
5
//
6
// Defines _setmaxstdio() and _getmaxstdio(), which control the maximum number
7
// of stdio streams that may be open simultaneously.
8
//
9
#include <
corecrt_internal_stdio.h
>
10
11
12
13
// Sets the maximum number of stdio streams that may be simultaneously open.
14
// Note that the maximum must be at least _IOB_ENTRIES, and must be no larger
15
// than _N_HANDLE_. However, it may be either larger or smaller than the current
16
// maximum.
17
//
18
// Returns the new maximum value on success; returns -1 on failure.
19
extern
"C"
int
__cdecl
_setmaxstdio
(
int
const
new_maximum)
20
{
21
// Make sure the request is reasonable:
22
_VALIDATE_RETURN
(new_maximum >=
_IOB_ENTRIES
&& new_maximum <=
_NHANDLE_
,
EINVAL
, -1);
23
24
return
__acrt_lock_and_call(
__acrt_stdio_index_lock
, [&]
25
{
26
// If the new maximum is the same as our current maximum, no work to do:
27
if
(new_maximum ==
_nstream
)
28
return
new_maximum;
29
30
// If the new maximum is smaller than the current maximum, attempt to
31
// free up any entries that are beyond the new maximum:
32
if
(new_maximum <
_nstream
)
33
{
34
__crt_stdio_stream_data
**
const
first_to_remove =
__piob
+ new_maximum;
35
__crt_stdio_stream_data
**
const
last_to_remove =
__piob
+
_nstream
;
36
for
(
__crt_stdio_stream_data
** rit = last_to_remove; rit != first_to_remove; --rit)
37
{
38
__crt_stdio_stream_data
*
const
entry
= *(rit - 1);
39
if
(
entry
==
nullptr
)
40
continue
;
41
42
// If the entry is still in use, stop freeing entries and return
43
// failure to the caller:
44
if
(
__crt_stdio_stream
(
entry
).is_in_use())
45
return
-1;
46
47
_free_crt
(
entry
);
48
}
49
}
50
51
// Enlarge or shrink the array, as required:
52
__crt_stdio_stream_data
**
const
new_piob = _recalloc_crt_t(
__crt_stdio_stream_data
*,
__piob
, new_maximum).detach();
53
if
(new_piob ==
nullptr
)
54
return
-1;
55
56
_nstream
= new_maximum;
57
__piob
= new_piob;
58
return
new_maximum;
59
});
60
}
61
62
63
64
// Gets the maximum number of stdio streams that may be open at any one time.
65
extern
"C"
int
__cdecl
_getmaxstdio
()
66
{
67
return
__acrt_lock_and_call(
__acrt_stdio_index_lock
, []
68
{
69
return
_nstream
;
70
});
71
}
EINVAL
#define EINVAL
Definition:
acclib.h:90
__cdecl
#define __cdecl
Definition:
accygwin.h:79
__crt_stdio_stream
Definition:
corecrt_internal_stdio.h:197
__acrt_stdio_index_lock
@ __acrt_stdio_index_lock
Definition:
corecrt_internal.h:946
_NHANDLE_
#define _NHANDLE_
Definition:
corecrt_internal_lowio.h:120
corecrt_internal_stdio.h
_nstream
int _nstream
Definition:
corecrt_internal_stdio.h:310
__piob
__crt_stdio_stream_data ** __piob
Definition:
corecrt_internal_stdio.h:316
_VALIDATE_RETURN
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
Definition:
corecrt_internal_strtox.h:38
_IOB_ENTRIES
#define _IOB_ENTRIES
Definition:
stdio.h:23
_free_crt
#define _free_crt
Definition:
internal_shared.h:175
entry
uint32_t entry
Definition:
isohybrid.c:63
_setmaxstdio
int __cdecl _setmaxstdio(int const new_maximum)
Definition:
setmaxf.cpp:19
_getmaxstdio
int __cdecl _getmaxstdio()
Definition:
setmaxf.cpp:65
__crt_stdio_stream_data
Definition:
corecrt_internal_stdio.h:167
sdk
lib
ucrt
stdio
setmaxf.cpp
Generated on Sun Apr 6 2025 06:17:26 for ReactOS by
1.9.6