1*04e0dc4aSTimo Kreuzer //
2*04e0dc4aSTimo Kreuzer // debug_fill_threshold.cpp
3*04e0dc4aSTimo Kreuzer //
4*04e0dc4aSTimo Kreuzer //      Copyright (c) Microsoft Corporation. All rights reserved.
5*04e0dc4aSTimo Kreuzer //
6*04e0dc4aSTimo Kreuzer // Functions to control the debug fill threshold used by the secure string
7*04e0dc4aSTimo Kreuzer // functions.  A threshold of 0 disables filling; a threshold of SIZE_MAX
8*04e0dc4aSTimo Kreuzer // means to always fill to the maximum.
9*04e0dc4aSTimo Kreuzer //
10*04e0dc4aSTimo Kreuzer #include <corecrt_internal.h>
11*04e0dc4aSTimo Kreuzer #include <stdint.h>
12*04e0dc4aSTimo Kreuzer 
13*04e0dc4aSTimo Kreuzer 
14*04e0dc4aSTimo Kreuzer 
15*04e0dc4aSTimo Kreuzer static size_t __acrt_debug_fill_threshold = SIZE_MAX;
16*04e0dc4aSTimo Kreuzer 
17*04e0dc4aSTimo Kreuzer 
18*04e0dc4aSTimo Kreuzer 
_CrtSetDebugFillThreshold(size_t const new_threshold)19*04e0dc4aSTimo Kreuzer extern "C" size_t __cdecl _CrtSetDebugFillThreshold(size_t const new_threshold)
20*04e0dc4aSTimo Kreuzer {
21*04e0dc4aSTimo Kreuzer     size_t const old_threshold{__acrt_debug_fill_threshold};
22*04e0dc4aSTimo Kreuzer     __acrt_debug_fill_threshold = new_threshold;
23*04e0dc4aSTimo Kreuzer     return old_threshold;
24*04e0dc4aSTimo Kreuzer }
25*04e0dc4aSTimo Kreuzer 
_CrtGetDebugFillThreshold()26*04e0dc4aSTimo Kreuzer extern "C" size_t __cdecl _CrtGetDebugFillThreshold()
27*04e0dc4aSTimo Kreuzer {
28*04e0dc4aSTimo Kreuzer     return __acrt_debug_fill_threshold;
29*04e0dc4aSTimo Kreuzer }
30