| 1 | /* $Id: malloc.h,v 1.4 1999-10-31 23:57:04 bird Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * Heap. | 
|---|
| 4 | * | 
|---|
| 5 | * Note: This heap does very little checking on input. | 
|---|
| 6 | *       Use with care! We're running at Ring-0! | 
|---|
| 7 | * | 
|---|
| 8 | * Copyright (c) 1999 knut st. osmundsen | 
|---|
| 9 | * | 
|---|
| 10 | */ | 
|---|
| 11 |  | 
|---|
| 12 | /* XLATOFF */ | 
|---|
| 13 | #ifndef _MALLOC_H_ | 
|---|
| 14 | #define _MALLOC_H_ | 
|---|
| 15 | #ifdef __MALLOC_H | 
|---|
| 16 | #error("A different version of malloc.h has allready been loaded!") | 
|---|
| 17 | #endif | 
|---|
| 18 | #define __malloc_h | 
|---|
| 19 |  | 
|---|
| 20 | #ifdef __cplusplus | 
|---|
| 21 | extern "C" { | 
|---|
| 22 | #endif | 
|---|
| 23 | /* XLATON */ | 
|---|
| 24 |  | 
|---|
| 25 | /******************************************************************************* | 
|---|
| 26 | *   Exported Functions and Variables                                           * | 
|---|
| 27 | *******************************************************************************/ | 
|---|
| 28 | int      heapInit(unsigned); | 
|---|
| 29 | void *   malloc(unsigned); | 
|---|
| 30 | void *   realloc(void *, unsigned); | 
|---|
| 31 | void     free(void *); | 
|---|
| 32 | unsigned _memfree(void); | 
|---|
| 33 | unsigned _msize(void *); | 
|---|
| 34 | int      _validptr(void *); | 
|---|
| 35 | int      _validptr2(void *, unsigned); | 
|---|
| 36 | int      _heap_check(void); | 
|---|
| 37 |  | 
|---|
| 38 | extern unsigned  _uHeapMinPtr;/* heap pointers are greater or equal to this.*/ | 
|---|
| 39 | extern unsigned  _uHeapMaxPtr;/* heap pointers are less than this. */ | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | /******************************************************************************* | 
|---|
| 43 | *   Defined Constants And Macros                                               * | 
|---|
| 44 | *******************************************************************************/ | 
|---|
| 45 | #define MINPTR _uHeapMinPtr | 
|---|
| 46 | #define MAXPTR _uHeapMaxPtr | 
|---|
| 47 |  | 
|---|
| 48 | /* HeapPointer assert - old ones... */ | 
|---|
| 49 | #define ltasserthp(a)         if (!_validptr((void*)(a))){ _ltasserthp((void*)(a), #a,__FILE__,__LINE__); return FALSE;} | 
|---|
| 50 | #define ltasserthp2(a,b)      if (!_validptr((void*)(a))){ _ltasserthp((void*)(a), #a,__FILE__,__LINE__); b; return FALSE;} | 
|---|
| 51 | #define _ltasserthp(a,b,c,d)  _kprintf("ltasserthp: pv=%#.8x - '%s' in %s line %d - returns FALSE\n",a,b,c,d) | 
|---|
| 52 | #define ltasserthps(a,b)          if (!_validptr2((void*)(a),(unsigned)(b))){ _ltasserthsp((void*)(a), (unsigned)(b), #a, #b,__FILE__,__LINE__); return FALSE;} | 
|---|
| 53 | #define ltasserthps2(a,b,c)       if (!_validptr2((void*)(a),(unsigned)(b))){ _ltasserthsp((void*)(a), (unsigned)(b), #a, #b,__FILE__,__LINE__); c; return FALSE;} | 
|---|
| 54 | #define _ltasserthps(a,b,c,d,e,f) _kprintf("ltasserthsp: pv=%#.8x cb=%#x - '%s' '%s' in %s line %d - returns FALSE\n",a,b,c,d,e,f) | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 | /* XLATOFF */ | 
|---|
| 58 | #ifdef __cplusplus | 
|---|
| 59 | } | 
|---|
| 60 | #endif | 
|---|
| 61 | #endif /* _MALLOC_H_ */ | 
|---|
| 62 | /* XLATON */ | 
|---|
| 63 |  | 
|---|