| 1 | /* $Id: malloc.h,v 1.5 1999-11-10 01:45:32 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 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | /* XLATOFF */
|
|---|
| 15 | #ifndef _MALLOC_H_
|
|---|
| 16 | #define _MALLOC_H_
|
|---|
| 17 | #ifdef __MALLOC_H
|
|---|
| 18 | #error("A different version of malloc.h has allready been loaded!")
|
|---|
| 19 | #endif
|
|---|
| 20 | #define __malloc_h
|
|---|
| 21 |
|
|---|
| 22 | #ifdef __cplusplus
|
|---|
| 23 | extern "C" {
|
|---|
| 24 | #endif
|
|---|
| 25 | /* XLATON */
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Exported Functions and Variables *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | int heapInit(unsigned);
|
|---|
| 31 | void * malloc(unsigned);
|
|---|
| 32 | void * realloc(void *, unsigned);
|
|---|
| 33 | void free(void *);
|
|---|
| 34 | unsigned _memfree(void);
|
|---|
| 35 | unsigned _msize(void *);
|
|---|
| 36 | int _validptr(void *);
|
|---|
| 37 | int _validptr2(void *, unsigned);
|
|---|
| 38 | int _heap_check(void);
|
|---|
| 39 |
|
|---|
| 40 | extern unsigned _uHeapMinPtr;/* heap pointers are greater or equal to this.*/
|
|---|
| 41 | extern unsigned _uHeapMaxPtr;/* heap pointers are less than this. */
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | /*******************************************************************************
|
|---|
| 45 | * Defined Constants And Macros *
|
|---|
| 46 | *******************************************************************************/
|
|---|
| 47 | #define MINPTR _uHeapMinPtr
|
|---|
| 48 | #define MAXPTR _uHeapMaxPtr
|
|---|
| 49 |
|
|---|
| 50 | /* HeapPointer assert - old ones... */
|
|---|
| 51 | #define ltasserthp(a) if (!_validptr((void*)(a))){ _ltasserthp((void*)(a), #a,__FILE__,__LINE__); return FALSE;}
|
|---|
| 52 | #define ltasserthp2(a,b) if (!_validptr((void*)(a))){ _ltasserthp((void*)(a), #a,__FILE__,__LINE__); b; return FALSE;}
|
|---|
| 53 | #define _ltasserthp(a,b,c,d) _kprintf("ltasserthp: pv=%#.8x - '%s' in %s line %d - returns FALSE\n",a,b,c,d)
|
|---|
| 54 | #define ltasserthps(a,b) if (!_validptr2((void*)(a),(unsigned)(b))){ _ltasserthsp((void*)(a), (unsigned)(b), #a, #b,__FILE__,__LINE__); return FALSE;}
|
|---|
| 55 | #define ltasserthps2(a,b,c) if (!_validptr2((void*)(a),(unsigned)(b))){ _ltasserthsp((void*)(a), (unsigned)(b), #a, #b,__FILE__,__LINE__); c; return FALSE;}
|
|---|
| 56 | #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)
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | /* XLATOFF */
|
|---|
| 60 | #ifdef __cplusplus
|
|---|
| 61 | }
|
|---|
| 62 | #endif
|
|---|
| 63 | #endif /* _MALLOC_H_ */
|
|---|
| 64 | /* XLATON */
|
|---|
| 65 |
|
|---|