_msize_dbg

(디버그 버전에만 해당) 힙의 메모리 블록의 크기를 계산합니다.

size_t _msize_dbg(
   void *userData,
   int blockType 
);

매개 변수

  • userData
    메모리 블록 크기를 결정 하는 작업에 대 한 포인터입니다.

  • blockType
    지정 된 메모리 블록 형식: _CLIENT_BLOCK 또는 _NORMAL_BLOCK.

반환 값

성공적으로 완료 되 면, _msize_dbg 지정 된 메모리 블록;의 크기를 바이트 단위로 반환 합니다. 그렇지 않으면 NULL을 반환 합니다.

설명

_msize_dbg_의 디버그 버전입니다msize 함수입니다.때 _DEBUG 정의 되지 않은 각 호출에 _msize_dbg 에 대 한 호출을 감소 _msize.둘 다 _msize_msize_dbg 기본 힙에서 메모리 블록의 크기를 계산 하지만 _msize_dbg 두 디버깅 기능 추가: 반환 된 크기는 버퍼 메모리 블록 사용자 부분의 포함 됩니다 및 특정 블록 형식에 대 한 크기를 계산할 수 있습니다.

메모리 블록 할당, 초기화 및 기본 힙의 디버그 버전에서 관리 하는 방법에 대 한 자세한 내용은 참조 하십시오. 메모리 관리 및 디버그 힙.할당 블록 종류 및 사용 방법에 대 한 자세한 내용은 의 디버그 힙의 블록 형식.응용 프로그램의 디버그 빌드를 호출 하는 표준 힙 함수 및 해당 디버그 버전 간의 차이점에 대 한 자세한 내용은 를 디버그 버전 대의 기본 버전을 사용 하 여.

이 함수는 매개 변수를 확인합니다.경우 memblock 는 null 포인터 _msize 에 설명 된 대로 잘못 된 매개 변수 처리기를 호출 합니다. 매개 변수 유효성 검사.오류를 처리 하는 경우 함수 설정 errnoEINVAL 및-1을 반환 합니다.

요구 사항

루틴

필수 헤더

_msize_dbg

<crtdbg.h>

더 많은 호환성 정보를 참조 하십시오. 호환성 소개에서 합니다.

라이브러리

디버그 버전의 C 런타임 라이브러리 만 합니다.

예제

// crt_msize_dbg.c
// compile with: /MTd
/*
 * This program allocates a block of memory using _malloc_dbg
 * and then calls _msize_dbg to display the size of that block.
 * Next, it uses _realloc_dbg to expand the amount of
 * memory used by the buffer and then calls _msize_dbg again to
 * display the new amount of memory allocated to the buffer.
 */

#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <crtdbg.h>

int main( void )
{
        long *buffer, *newbuffer;
        size_t size;

        /* 
         * Call _malloc_dbg to include the filename and line number
         * of our allocation request in the header
         */
        buffer = (long *)_malloc_dbg( 40 * sizeof(long), _NORMAL_BLOCK, __FILE__, __LINE__ );
        if( buffer == NULL )
               exit( 1 );

        /* 
         * Get the size of the buffer by calling _msize_dbg
         */
        size = _msize_dbg( buffer, _NORMAL_BLOCK );
        printf( "Size of block after _malloc_dbg of 40 longs: %u\n", size );

        /* 
         * Reallocate the buffer using _realloc_dbg and show the new size
         */
        newbuffer = _realloc_dbg( buffer, size + (40 * sizeof(long)), _NORMAL_BLOCK, __FILE__, __LINE__ );
        if( newbuffer == NULL )
               exit( 1 );
        buffer = newbuffer;
        size = _msize_dbg( buffer, _NORMAL_BLOCK );
        printf( "Size of block after _realloc_dbg of 40 more longs: %u\n", size );

        free( buffer );
        exit( 0 );
}

Output

Size of block after _malloc_dbg of 40 longs: 160
Size of block after _realloc_dbg of 40 more longs: 320

해당 .NET Framework 항목

해당 사항 없음. 표준 C 함수를 호출할 수 있습니다 PInvoke. 자세한 내용은 플랫폼 호출 예제.

참고 항목

참조

루틴을 디버깅 합니다.

_malloc_dbg