Share via


_CrtSetDebugFillThreshold

デバッグ関数の限界制御のバッファー設定動作を取得するか、または変更します。

size_t _CrtSetDebugFillThreshold(
   size_t _NewThreshold
);

パラメーター

  • newThreshold
    新しいしきい値。

戻り値

前のしきい値。

解説

一部のデバッグ バージョンは、特殊文字 (0xFD) のセキュリティが強化された CRT 関数、渡されたバッファーを塗りつぶします。 これにより、不適切なサイズが関数に渡されたケースを見つけることができます。 ただし、これは、パフォーマンスを低下させます。 パフォーマンスを向上させるために、しきい値よりも大きいバッファーのバッファーを満たすされた無効にするために _CrtSetDebugFillThreshold を使用します。 0 のしきい値はすべてのバッファーには無効にします。

既定のしきい値は、SIZE_T_MAXです。

影響を受ける関数の一覧を次に示します。

必要条件

ルーチン

必須ヘッダー

_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 を使用します。詳細については、「プラットフォーム呼び出しの例」を参照してください。

参照

関連項目

デバッグ ルーチン