/** * Allocates a new block of shared LIBCX memory. Must be called under * global_lock(). */ void *global_alloc(size_t size) { #ifdef STATS_ENABLED void *result = _ucalloc(gpData->heap, 1, size); if (result) { _HEAPSTATS hst; if (_ustats(gpData->heap, &hst) == 0 && gpData->max_heap_used < hst._used) gpData->max_heap_used = hst._used; } return result; #else return _ucalloc(gpData->heap, 1, size); #endif }
void *os2ldcalloc(size_t num_elem, size_t size_elem) { APIRET rc; int ret; if (FirstTime) { if ((rc=DosAllocMem(&os2ldBase,RESERVED_BLOCKS * 4096, PAG_READ | PAG_WRITE | PAG_EXECUTE)) != 0) { xf86Msg(X_ERROR, "OS2LD: DosAllocMem failed, rc=%d\n", rc); return NULL; } /* Now commit the first 128Kb, the rest will * be done dynamically */ if ((rc=DosSetMem(os2ldBase, 32*4096, PAG_DEFAULT | PAG_COMMIT)) != 0) { xf86Msg(X_ERROR, "OS2LD: DosSetMem failed, rc=%d\n",rc); DosFreeMem(os2ldBase); return NULL; } os2ldCommitedTop = os2ldBase + 32*4096; os2ldTotalCommitedBlocks = 32; #ifdef DEBUG xf86Msg(X_INFO, "OS2LD: Initial heap at addr=%p\n", os2ldBase); #endif if ((os2ldHeap=_ucreate(os2ldBase, 32*4096, _BLOCK_CLEAN, _HEAP_REGULAR, os2ldAddToHeap, os2ldRemoveFromHeap)) == NULL) { xf86Msg(X_ERROR, "OS2LD: heap creation failed\n"); DosFreeMem(os2ldBase); return NULL; } if ((ret=_uopen(os2ldHeap)) != 0) { xf86Msg(X_ERROR, "OS2LD: heap open failed\n"); ret = _udestroy(os2ldHeap,_FORCE); DosFreeMem(os2ldBase); return(NULL); } FirstTime = FALSE; #ifdef DEBUG xf86Msg(X_INFO,"OS2LD: Created module heap at addr=%p\n", os2ldHeap); #endif } return _ucalloc(os2ldHeap,num_elem,size_elem); }