/* impotrs.cpp */ /* extract from G:\EVGEN\MESA5\MesaDLL\imports.cpp */ #define F_INCL_DOSMISC /* DOS Miscellaneous values */ #include "imports.h" #include "context.h" extern int InitHiMemory(void); /**********************************************************************/ /* Wrappers for standard C library functions */ /**********************************************************************/ /********************************************************************** * Memory */ int TotalRam=0; int TotalRaz=0; int TotalRaz1=0; extern void * (* _pmesa_malloc)(size_t bytes); extern void * (* _pmesa_calloc)(size_t num, size_t bytes); void * _mesa_malloc(size_t bytes) { #if defined(XFree86LOADER) && defined(IN_MODULE) return xf86malloc(bytes); #else void *p; p = _pmesa_malloc(bytes); if(p == NULL) { printf("ERROR: Out of memory for %u bytes at %s\n",bytes, __FUNCTION__); exit(1); } // TotalRam += bytes; // TotalRaz++; // printf("malloc RAM=%i,=%i,%i ",TotalRam ,TotalRaz,bytes); return p; #endif } void * _mesa_calloc(size_t bytes) { #if defined(XFree86LOADER) && defined(IN_MODULE) return xf86calloc(1, bytes); #else void *p; p = _pmesa_calloc(1, bytes); if(p == NULL) { printf("ERROR: Out of memory for %u bytes at %s\n",bytes, __FUNCTION__); exit(1); } // TotalRam += bytes; // TotalRaz1++; // printf("calloc RAM=%i,raz=%i,bytes=%i\n",TotalRam ,TotalRaz1,bytes); // testRAM(); return p; #endif } void _mesa_free(void *ptr) { #if defined(XFree86LOADER) && defined(IN_MODULE) xf86free(ptr); #else // TotalRam -= _msize(ptr); free(ptr); #endif } void * _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) { const size_t copySize = (oldSize < newSize) ? oldSize : newSize; void *newBuffer = _mesa_malloc(newSize); if (newBuffer && copySize > 0) _mesa_memcpy(newBuffer, oldBuffer, copySize); if (oldBuffer) _mesa_free(oldBuffer); return newBuffer; } void _mesa_init_default_imports(__GLimports *imports, void *driverCtx) { /* [...] */ InitHiMemory(); }