_CrtSetDebugFillThreshold
を取得またはデバッグ機能の制限を制御するバッファーへの動作を変更します。
size_t _CrtSetDebugFillThreshold(
size_t _NewThreshold
);
パラメーター
- newThreshold
新しいしきい値。
戻り値
前のしきい値。
解説
一部のデバッグ バージョンはセキュリティが強化された CRT 関数の特殊文字 (0xFD) で渡されたバッファーに格納します。これにより不適切なサイズが関数に渡されたケースを検索できます。ただしパフォーマンスが低下します。パフォーマンスを向上させるためにしきい値よりも大きい場合にバッファーに格納するバッファーを無効にするに _CrtSetDebugFillThreshold を使用します。0 のしきい値はすべてのバッファーのビューステートを無効にします。
既定のしきい値は SIZE_T_MAX です。
影響を受ける関数の一覧を示します。
strncpy_s、_strncpy_s_l、wcsncpy_s、_wcsncpy_s_l、_mbsncpy_s、_mbsncpy_s_l
strncat_s、_strncat_s_l、wcsncat_s、_wcsncat_s_l、_mbsncat_s、_mbsncat_s_l
_strnset_s、_strnset_s_l、_wcsnset_s、_wcsnset_s_l、_mbsnset_s、_mbsnset_s_l
_strlwr_s、_strlwr_s_l、_mbslwr_s、_mbslwr_s_l、_wcslwr_s、_wcslwr_s_l
_strupr_s、_strupr_s_l、_mbsupr_s、_mbsupr_s_l、_wcsupr_s、_wcsupr_s_l
必要条件
ルーチン |
必須ヘッダー |
---|---|
_CrtSetDebugFillThreshold |
<crtdbg.h> |
互換性の詳細については、「C ランタイム ライブラリ」の「互換性」を参照してください。
ライブラリ
C ランタイム ライブラリのデバッグ バージョンのみ。
使用例
// crt_crtsetdebugfillthreshold.cpp
// compile with: /MTd
#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
fd ²
fd ²
fd ²
fd ²
With buffer-filling off:
68 h
6f o
77 w
64 d
79 y
00
00
00
00
00
同等の .NET Framework 関数
該当なし標準 C 関数を呼び出すには、PInvoke を使用します。詳細については、「プラットフォーム呼び出しの例」を参照してください。