_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

另请参阅

调试例程