_CrtSetDebugFillThreshold
デバッグ関数でバッファーへの格納動作を制御するしきい値を取得または変更します。
構文
size_t _CrtSetDebugFillThreshold( size_t newThreshold );
パラメーター
newThreshold
新しいしきい値のサイズ (バイト単位)。
戻り値
前のしきい値。
解説
セキュリティが強化された CRT 関数のデバッグ バージョンでは、それに渡されたバッファーを特殊文字 (0xFE) で埋めます。 この充填文字により、関数に不適切なサイズが渡された場合に、それを見つけることができます。 残念ながら、パフォーマンスを低下させます。 パフォーマンスを向上させるには、 _CrtSetDebugFillThreshold
しきい値より大きいバッファーのバッファーフィルを newThreshold
無効にします。 newThreshold
値が 0 の場合、すべてのバッファーで無効になります。
既定のしきい値は SIZE_T_MAX
です。
影響を受ける関数の一覧を次に示します。
ctime_s
,_ctime32_s
,_ctime64_s
,_wctime_s
,_wctime32_s
,_wctime64_s
_itoa_s
,_ltoa_s
,_ultoa_s
,_i64toa_s
,_ui64toa_s
,_itow_s
,_ltow_s
,_ultow_s
,_i64tow_s
,_ui64tow_s
_strlwr_s
,_strlwr_s_l
,_mbslwr_s
,_mbslwr_s_l
,_wcslwr_s
,_wcslwr_s_l
strncat_s
,_strncat_s_l
,wcsncat_s
,_wcsncat_s_l
,_mbsncat_s
,_mbsncat_s_l
strncpy_s
,_strncpy_s_l
,wcsncpy_s
,_wcsncpy_s_l
,_mbsncpy_s
,_mbsncpy_s_l
_strnset_s
,_strnset_s_l
,_wcsnset_s
,_wcsnset_s_l
,_mbsnset_s
,_mbsnset_s_l
_strset_s
,_strset_s_l
,_wcsset_s
,_wcsset_s_l
,_mbsset_s
,_mbsset_s_l
_strupr_s
,_strupr_s_l
,_mbsupr_s
,_mbsupr_s_l
,_wcsupr_s
,_wcsupr_s_l
必要条件
ルーチンによって返される値 | 必須ヘッダー |
---|---|
_CrtSetDebugFillThreshold |
<crtdbg.h> |
この関数は、Microsoft 固有の関数です。 互換性の詳細については、「 Compatibility」を参照してください。
ライブラリ
C ランタイム ライブラリのデバッグ バージョンのみ。
例
// crt_crtsetdebugfillthreshold.c
// compile with: cl /MTd crt_crtsetdebugfillthreshold.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crtdbg.h>
void Clear( char buff[], size_t size )
{
for( int i=0; i<size; ++i )
buff[i] = 0;
}
void Print( char buff[], size_t size )
{
for( int i=0; i<size; ++i )
printf( "%02x %c\n", (unsigned char)buff[i], buff[i] );
}
int main( void )
{
char buff[10];
printf( "With buffer-filling on:\n" );
strcpy_s( buff, _countof(buff), "howdy" );
Print( buff, _countof(buff) );
_CrtSetDebugFillThreshold( 0 );
printf( "With buffer-filling off:\n" );
Clear( buff, _countof(buff) );
strcpy_s( buff, _countof(buff), "howdy" );
Print( buff, _countof(buff) );
}
With buffer-filling on:
68 h
6f o
77 w
64 d
79 y
00
fe ■
fe ■
fe ■
fe ■
With buffer-filling off:
68 h
6f o
77 w
64 d
79 y
00
00
00
00
00
関連項目
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示