Ignore:
Timestamp:
Oct 6, 2001, 8:53:11 PM (24 years ago)
Author:
sandervl
Message:

reduce heap overhead + always allocate from high memory

File:
1 edited

Legend:

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

    r6412 r6954  
    1 /* $Id: os2heap.cpp,v 1.23 2001-07-30 12:01:24 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.24 2001-10-06 18:53:11 sandervl Exp $ */
    22
    33/*
     
    4343
    4444void * _LNK_CONV getmoreHeapMem(Heap_t pHeap, size_t *size, int *clean);
    45 void _LNK_CONV  releaseHeapMem(Heap_t pHeap, void *block, size_t size);
     45void   _LNK_CONV releaseHeapMem(Heap_t pHeap, void *block, size_t size);
    4646
    4747//******************************************************************************
     
    6161  this->dwInitialSize = dwInitialSize;
    6262  this->flOptions     = flOptions;
    63 
    64   if(!(flOptions & HEAP_NO_SERIALIZE))
    65   {
    66     hmutex = new VMutex();
    67     dassert(hmutex, ("ERROR: new VMutex\n"));
    68   }
    69   else  hmutex = NULL;
    7063
    7164  heaplistmutex.enter();
     
    10497{
    10598 OS2Heap *curheap = OS2Heap::heap;
    106  HEAPELEM *hnext;
    10799 int i;
    108100
    109101  dprintf(("dtr OS2Heap, hPrimaryHeap = %X\n", hPrimaryHeap));
    110 
    111   if(hmutex)
    112     hmutex->enter();
    113 
    114   while(heapelem) {
    115     hnext = heapelem->next;
    116     free(heapelem->lpMem);
    117     heapelem = hnext;
    118   }
    119   if(hmutex)
    120   {
    121     hmutex->leave();
    122     delete(hmutex);
    123   }
    124102
    125103  heaplistmutex.enter();
     
    171149  lpHeapObj = (HEAPELEM *)(((ULONG)lpMem+7) & ~7);
    172150  lpHeapObj->lpMem = lpMem;
    173 
    174   if(hmutex)
    175       hmutex->enter();
    176 
    177   lpHeapObj->next    = heapelem;
    178   lpHeapObj->prev    = NULL;
    179151  lpHeapObj->magic   = MAGIC_NR_HEAP;
    180   if(heapelem) {
    181       heapelem->prev = lpHeapObj;
    182   }
    183   heapelem           = lpHeapObj;
    184 
    185   if(hmutex) {
    186       hmutex->leave();
    187   }
     152
    188153  return(LPVOID)(lpHeapObj+1);
    189154}
     
    278243  totalAlloc -= size;
    279244#endif
    280   if(hmutex)
    281     hmutex->enter();
    282 
    283   if(helem->prev)
    284         helem->prev->next = helem->next;
    285   if(helem->next)
    286         helem->next->prev = helem->prev;
    287   if(heapelem == helem)
    288         heapelem = heapelem->next;
    289 
    290   if(hmutex) {
    291         hmutex->leave();
    292   }
    293245
    294246  free(helem->lpMem);
     
    371323  *size = (*size / 4096) * 4096 + 4096;
    372324
    373   rc = DosAllocMem(&newblock, *size, PAG_READ|PAG_WRITE|PAG_COMMIT|PAG_EXECUTE);
     325  rc = DosAllocMem(&newblock, *size, flAllocMem|PAG_READ|PAG_WRITE|PAG_COMMIT|PAG_EXECUTE);
    374326  if(rc != 0) {
    375327        dprintf(("getmoreHeapMem: DosAllocMem failed with %d", rc));
    376328        return FALSE;
    377329  }
     330success:
    378331  *clean = _BLOCK_CLEAN;
    379332  dprintf(("KERNEL32: getmoreHeapMem %x %d", newblock, *size));
Note: See TracChangeset for help on using the changeset viewer.