Changeset 1271 for trunk/src/win32k/misc/malloc.c
- Timestamp:
- Oct 14, 1999, 3:19:22 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/malloc.c
r847 r1271 1 /* $Id: malloc.c,v 1. 1 1999-09-06 02:20:02bird Exp $1 /* $Id: malloc.c,v 1.2 1999-10-14 01:19:21 bird Exp $ 2 2 * 3 3 * Heap. … … 19 19 20 20 #define SIGNATURE 0xBEEFFEEB 21 #define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */ 21 /*#define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */ 22 #define CB_HDR (int)&(((PMEMBLOCK)0)->achUserData[0]) 22 23 #define PNEXT_BLOCK(a) ((PMEMBLOCK)((unsigned)(a) + CB_HDR + (a)->cbSize)) 23 24 … … 25 26 #define INCL_DOSERRORS 26 27 #ifdef RING0 27 #define INCL_NOAPI28 #define INCL_NOAPI 28 29 #else 29 #define INCL_DOSMEMMGR30 #define INCL_DOSMEMMGR 30 31 #endif 32 31 33 32 34 /****************************************************************************** … … 34 36 ******************************************************************************/ 35 37 #include <os2.h> 36 38 #ifdef RING0 39 #include "dev32hlp.h" 40 #include "asmutils.h" 41 #else 42 #include <builtin.h> 43 #define Int3() __interrupt(3) 44 #endif 37 45 #include "log.h" 38 #include "dev32hlp.h"39 #include "asmutils.h"40 46 #include "malloc.h" 41 #include "memory.h"47 #include <memory.h> 42 48 43 49 … … 45 51 * Structs and Typedefs 46 52 ******************************************************************************/ 53 #pragma pack(1) 47 54 typedef struct _MEMBLOCK /* MB */ 48 55 { … … 54 61 unsigned char achUserData[1]; 55 62 } MEMBLOCK, *PMEMBLOCK; 56 63 #pragma pack() 57 64 58 65 /****************************************************************************** 59 66 * Global data 60 67 ******************************************************************************/ 68 /*#pragma info(nogen, nouni, noext)*/ 61 69 static PMEMBLOCK pUsed; /* pointer to the used memblock chain. */ 62 70 static PMEMBLOCK pFree; /* pointer to the free memblock chain. */ 63 71 static unsigned cbFree; /* bytes of free user memory in the heap.*/ 64 unsigned _uHeapMinPtr; /* heap pointers are greater or equal to this.*/ 65 unsigned _uHeapMaxPtr; /* heap pointers are less than this. */ 72 unsigned _uHeapMinPtr; /* heap pointers are greater or equal to this.*/ 73 unsigned _uHeapMaxPtr; /* heap pointers are less than this. */ 74 #ifndef RING0 75 char fInited; /* init flag */ 76 #endif 66 77 67 78 /****************************************************************************** … … 277 288 pUsed = NULL; 278 289 279 #if RING0290 #ifdef RING0 280 291 pFree = D32Hlp_VMAlloc(VMDHA_SWAP | VMDHA_USEHIGHMEM, cbSize, ~0UL); 281 292 #else 282 if (DosAllocMem( &pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)283 pFree = NULL 293 if (DosAllocMem((void*)&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0) 294 pFree = NULL; 284 295 #endif 285 296 if (pFree == NULL) … … 308 319 return -2; 309 320 } 321 #endif 322 #ifdef RING3 323 fInited = TRUE; 310 324 #endif 311 325 return 0; … … 323 337 { 324 338 void *pvRet = NULL; 339 325 340 #ifdef DEBUG_ALLOC 326 341 if (!_heap_check()) … … 384 399 pvRet = malloc(cbNew); 385 400 if (pvRet != NULL) 401 { 386 402 memcpy(pvRet, pv, pMemblock->cbSize); 387 } 388 403 free(pv); 404 } 405 } 406 return pvRet; 389 407 } 390 408 return NULL; … … 598 616 599 617 618 #if !defined(RING0) && defined(__IBMC__) 619 620 /** 621 * Initialize Memory Functions 622 * Called from _exeentry. 623 */ 624 int _rmem_init(void) 625 { 626 int rc = heapInit(HEAP_SIZE); 627 return rc; 628 } 629 630 /** 631 * Initialize Memory Functions 632 * Called from _exeentry. 633 */ 634 int _rmem_term(void) 635 { 636 return 0; 637 } 638 639 #endif
Note:
See TracChangeset
for help on using the changeset viewer.