C6331
C6331 Uyarı: Geçersiz parametre: mem_release ve MEM_DECOMMIT <function> için birlikte geçirme izin verilmez.Bu, bu görüşme hatasına neden olur
Bu ileti, VirtualFree veya VirtualFreeEx geçirilen geçersiz bir parametre gösterir.VirtualFree ve VirtualFreeEx bayrakları Reddet (mem_release | MEM_DECOMMIT) birlikte.Bu nedenle, MEM_DECOMMIT ve mem_release değerleri birlikte aynı çağrıda kullanılabilir değil.
Decommit ve bağımsız adımlardan oluşan yayın için gerekli değildir.Kaydedilmiş bellek serbest sayfalar aynı zamanda kaydettikleri.Ayrıca, bu işlevin dönüş değeri yok sayılır emin olun.
Örnek
Aşağıdaki örnek kod, bu uyarı oluşturur:
#include <windows.h>
#define PAGELIMIT 80
DWORD dwPages = 0; // count of pages
DWORD dwPageSize; // page size
VOID fd( 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_DECOMMIT | MEM_RELEASE); // warning
// code...
}
Bu uyarı düzeltmek için MEM_DECOMMIT değeri aşağıdaki kodda gösterildiği gibi VirtualFree çağrı iletmeyen:
#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...
}