Share via


_CrtSetDebugFillThreshold

更新 : 2007 年 11 月

デバッグ関数におけるバッファ入力動作を制御するしきい値を取得または変更します。

size_t _CrtSetDebugFillThreshold(
   size_t _NewThreshold
);

パラメータ

  • newThreshold
    新しいしきい値。

戻り値

前のしきい値。

解説

セキュリティが強化されたいくつかの CRT 関数のデバッグ バージョンは、渡されたバッファに特殊文字 (0xFD) を書き込みます。これにより、正しくないサイズが関数に渡された場合、これを発見しやすくなります。ただし、これはパフォーマンスに影響します。パフォーマンスを改善するには、_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 を使用します。詳細については、「プラットフォーム呼び出しの例」を参照してください。

参照

参照

デバッグ ルーチン