Share via


_CrtSetDebugFillThreshold

检索或修改阈值控件缓冲区加载的行为调试功能。

size_t _CrtSetDebugFillThreshold(
   size_t _NewThreshold
);

参数

  • newThreshold
    新的阈值。

返回值

前面的阈值。

备注

数组的调试版本安全增强的 CRT 函数使用特殊字符 (0xfd) 加载缓冲区传递给它们。 这有助于查找大小不正确传递给函数的大小写。 遗憾的是,它还会降低性能。 为了提高性能,超过了您使用 _CrtSetDebugFillThreshold 禁用缓冲加载缓冲区的。 阈值 0 将禁用它的任何缓冲区的。

默认阈值。 SIZE_T_MAX

这是受影响的功能的列表。

要求

实例

必需的头

_CrtSetDebugFillThreshold

crtdbg.h

有关更多兼容性信息,请参见中介绍的 兼容性

只调试 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。有关更多信息,请参见 平台调用示例

请参见

参考

调试实例