_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 特定的。 如需相容性詳細資訊,請參閱相容性。
程式庫
僅偵 錯 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 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應