Changeset 6954 for trunk/src


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

reduce heap overhead + always allocate from high memory

Location:
trunk/src/kernel32
Files:
2 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));
  • trunk/src/kernel32/os2heap.h

    r6397 r6954  
    1 /* $Id: os2heap.h,v 1.7 2001-07-28 18:03:38 sandervl Exp $ */
     1/* $Id: os2heap.h,v 1.8 2001-10-06 18:53:11 sandervl Exp $ */
    22
    33/*
     
    2323  DWORD  magic;     //magic number
    2424  LPVOID lpMem;     //pointer returned by malloc
    25   struct _tagHEAPELEM *prev;
    26   struct _tagHEAPELEM *next;
    2725} HEAPELEM;
    2826
    29 //extra overhead needed for quake 2 or 3 (a long time ago...)
    30 //#define HEAP_OVERHEAD (sizeof(HEAPELEM)+60)
    3127//+8 to make sure we can align the pointer at 8 byte boundary
    3228#define HEAP_OVERHEAD (sizeof(HEAPELEM)+8)
     
    5551protected:
    5652
    57     VMutex *hmutex;
    58 
    5953    DWORD     dwMaximumSize, dwInitialSize, flOptions, totalAlloc, nrHeaps;
    6054    HANDLE    hPrimaryHeap;
Note: See TracChangeset for help on using the changeset viewer.