共用方式為


_CrtSetDebugFillThreshold

檢索或修改調試函數中控制緩衝區填充行為的閾值。

語法

size_t _CrtSetDebugFillThreshold( size_t newThreshold );

參數

newThreshold
新的閾值大小(以位元組為單位)。

返回值

上一個閾值。

備註

某些安全增強型 CRT 函數的調試版本使用特殊字元 (0xFE) 填充傳遞給它們的緩衝區。 用於填充的字元有助於尋找將錯誤大小傳遞給函數的情況。 不幸的是,它也降低了性能。 要提高性能,請使用 _CrtSetDebugFillThreshold 禁用大於 newThreshold 閾值的緩衝區填充。 值為 newThreshold 0 將對所有緩衝區禁用它。

預設閾值為 SIZE_T_MAX

以下是受影響的函數清單:

需求

常規 必要的標頭
_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

另請參閱

調試例程