Share via


C6332

경고 C6332: 매개 변수가 잘못되었습니다. <function>에 dwFreeType 매개 변수로 0을 전달하면 호출이 실패합니다.

이 경고는 VirtualFree 또는 VirtualFreeEx에 잘못된 매개 변수가 전달되고 있다는 것을 나타냅니다. VirtualFree와 VirtualFreeEx는 0인 dwFreeType 매개 변수를 거부합니다. dwFreeType 매개 변수는 MEM_DECOMMIT 또는 MEM_RELEASE일 수 있습니다. 하지만 MEM_DECOMMIT 및 MEM_RELEASE 값은 같은 호출에 함께 사용할 수 없습니다. 또한 VirtualFree 함수의 반환 값이 무시되지 않도록 해야 합니다.

예제

다음 코드에서는 VirtualFree 함수에 잘못된 매개 변수가 전달되기 때문에 이 경고가 생성됩니다.

#include <windows.h>
#define PAGELIMIT 80            

DWORD dwPages = 0;  // count of pages 
DWORD dwPageSize;   // page size 

VOID f( VOID )
{
  LPVOID lpvBase;            // base address of the test memory
  BOOL bSuccess;           
  SYSTEM_INFO sSysInfo;      // system information

  GetSystemInfo( &sSysInfo );  
  dwPageSize = sSysInfo.dwPageSize;

  // Reserve pages in the process's virtual address space
  lpvBase = VirtualAlloc(
                         NULL,                // system selects address
                         PAGELIMIT*dwPageSize, // size of allocation
                         MEM_RESERVE,        
                         PAGE_NOACCESS );     
  if (lpvBase)
  {
    // code to access memory 
  }
  else
  {
    return;
  }

  bSuccess = VirtualFree( lpvBase, 0, 0 ); 
  // code ...
}

이 경고를 해결하려면 다음 코드에서처럼 VirtualFree 함수에 대한 호출을 수정합니다.

#include <windows.h>
#define PAGELIMIT 80            

DWORD dwPages = 0;  // count of pages 
DWORD dwPageSize;   // page size 

VOID f( VOID )
{
  LPVOID lpvBase;            // base address of the test memory
  BOOL bSuccess;           
  SYSTEM_INFO sSysInfo;      // system information

  GetSystemInfo( &sSysInfo );  
  dwPageSize = sSysInfo.dwPageSize;

  // Reserve pages in the process's virtual address space
  lpvBase = VirtualAlloc(
                         NULL,                // system selects address
                         PAGELIMIT*dwPageSize, // size of allocation
                         MEM_RESERVE,        
                         PAGE_NOACCESS );     
  if (lpvBase)
  {
    // code to access memory 
  }
  else
  {
    return;
  }

  bSuccess = VirtualFree( lpvBase, 0, MEM_RELEASE );
  // code ...
} 

참고 항목

참조

IHostMemoryManager::VirtualAlloc 메서드

IHostMemoryManager::VirtualFree 메서드