次の方法で共有


_CrtSetDebugFillThreshold

デバッグ関数のバッファ充満動作を制御するしきい値を取得または変更します。

構文

size_t _CrtSetDebugFillThreshold( size_t newThreshold );

パラメーター

newThreshold
新しいしきい値サイズ (バイト単位)。

戻り値

前のしきい値。

注釈

一部のセキュリティ拡張 CRT 関数のデバッグ バージョンでは、渡されたバッファーに特殊文字 (0xFE) が格納されます。 この充填文字により、関数に不適切なサイズが渡された場合に、それを見つけることができます。 残念ながら、性能も低下します。 パフォーマンスを向上させるには、 _CrtSetDebugFillThreshold を使用して、 newThreshold しきい値より大きいバッファーのバッファー充填を無効にします。 newThreshold値を 0 にすると、すべてのバッファーで無効になります。

デフォルトのしきい値は SIZE_T_MAX です。

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

要求事項

ルーチンによって返される値 必須ヘッダー
_CrtSetDebugFillThreshold <crtdbg.h>

この機能は Microsoft 固有です。 互換性の詳細については、「 Compatibility」を参照してください。

ライブラリ

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

こちらも参照ください

デバッグルーチン