Ignore:
Timestamp:
Oct 6, 1999, 11:58:24 AM (26 years ago)
Author:
phaller
Message:

Fix: VirtualFree not freeing memory fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/virtual.cpp

    r780 r1151  
    1 /* $Id: virtual.cpp,v 1.12 1999-09-01 19:12:18 phaller Exp $ */
     1/* $Id: virtual.cpp,v 1.13 1999-10-06 09:58:24 phaller Exp $ */
    22
    33/*
     
    1515 *
    1616 */
     17
     18#include <odin.h>
     19#include <odinwrap.h>
    1720
    1821#include <os2win.h>
     
    2427#include "mmap.h"
    2528#include "oslibdos.h"
     29
     30
     31ODINDEBUGCHANNEL(KERNEL32-VIRTUAL)
     32
    2633
    2734/***********************************************************************
     
    358365//******************************************************************************
    359366//******************************************************************************
    360 BOOL WIN32API VirtualFree(LPVOID lpvAddress, DWORD cbSize, DWORD FreeType)
    361 {
    362  DWORD rc;
    363 
    364   dprintf(("VirtualFree at %d; %d bytes, freetype %d\n", (int)lpvAddress, cbSize, FreeType));
    365 
    366   if(lpvAddress == NULL || cbSize == 0) {
    367         SetLastError(ERROR_INVALID_PARAMETER);
    368         return(FALSE);
    369   }
    370   if(FreeType & MEM_DECOMMIT) {
    371         rc = OSLibDosSetMem(lpvAddress, cbSize, PAG_DECOMMIT);
    372   }
    373   else  rc = OSLibDosFreeMem(lpvAddress);    //MEM_RELEASE, cbSize == 0 (or should be)
    374 
    375   if(rc) {
    376         SetLastError(ERROR_GEN_FAILURE);
    377         return(FALSE);
    378   }
     367ODINFUNCTION3(BOOL, VirtualFree, LPVOID, lpvAddress,
     368                                 DWORD,  cbSize,
     369                                 DWORD,  FreeType)
     370{
     371  DWORD rc;
     372
     373  // verify parameters
     374  if ( (lpvAddress == NULL) ||
     375       ( (FreeType & MEM_RELEASE) &&
     376         (cbSize   != 0) )
     377     )
     378  {
     379    SetLastError(ERROR_INVALID_PARAMETER);
     380    return(FALSE);
     381  }
     382
     383  if(FreeType & MEM_DECOMMIT)
     384    rc = OSLibDosSetMem(lpvAddress, cbSize, PAG_DECOMMIT);
     385  else
     386    rc = OSLibDosFreeMem(lpvAddress);    //MEM_RELEASE, cbSize == 0 (or should be)
     387
     388  if(rc)
     389  {
     390    SetLastError(ERROR_GEN_FAILURE);
     391    return(FALSE);
     392  }
     393
    379394  return(TRUE);
    380395}
Note: See TracChangeset for help on using the changeset viewer.