Ignore:
Timestamp:
Nov 10, 1999, 3:16:01 PM (26 years ago)
Author:
sandervl
Message:

VirtualAlloc fixes & changes

File:
1 edited

Legend:

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

    r1628 r1687  
    1 /* $Id: oslibdos.cpp,v 1.6 1999-11-08 13:43:12 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.7 1999-11-10 14:16:01 sandervl Exp $ */
    22
    33/*
     
    3232}
    3333//******************************************************************************
     34//NT returns addresses aligned at 64k, so we do too.
    3435//******************************************************************************
    3536DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD size, DWORD flags)
    3637{
    37   return DosAllocMem(lplpMemAddr, size, flags | flAllocMem);
     38 LPVOID memaddr;
     39 DWORD  offset;
     40 APIRET rc;
     41
     42  rc = DosAllocMem(&memaddr, size, PAG_READ | flAllocMem);
     43  if(rc) {
     44        return rc;
     45  }
     46  DosEnterCritSec();
     47  DosFreeMem(memaddr);
     48  offset = (DWORD)memaddr & 0xFFFF;
     49  if(offset) {
     50        DosAllocMem(&memaddr, 64*1024 - offset, PAG_READ | flAllocMem);
     51  }
     52  rc = DosAllocMem(lplpMemAddr, size, flags | flAllocMem);
     53  DosExitCritSec();
     54  if((DWORD)*lplpMemAddr & 0xFFFF) {//still not at 64k boundary?
     55        DosFreeMem(*lplpMemAddr);
     56        rc = OSLibDosAllocMem(lplpMemAddr, size, flags);
     57  }
     58  if(offset) {
     59        DosFreeMem(memaddr);
     60  }
     61
     62  return rc;
    3863}
    3964//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.