-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheap.h
More file actions
67 lines (52 loc) · 1.74 KB
/
heap.h
File metadata and controls
67 lines (52 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* heap.h - A portable dynamic memory heap manager
*
* Written by Graham Wheeler, January 1995.
* (c) 1995, All Rights Reserved
*
* See heap.c for documentation.
*
* Last modified:
* 29-1-95 Fixed to handle large heaps
*
* Contact: gram@aztec.co.za
*/
#ifndef _HEAP_H
#define _HEAP_H
#ifdef LOCAL_HEAP
/* Note that we use macros for the standard names, rather than
defining actual malloc, etc routines. This is because malloc
is called by the startup code before main() is executed, and
we don't want to replace those calls (if we do, then the
routines should be renamed and any macros below that end up in the
form "#define X X" should be removed) */
/* Support routines */
void GWsetheap(char far *base, unsigned long extent);
unsigned long GWheap_used();
unsigned long GWheap_avail();
void GWheapstatus(int detailed);
#define setheap(b, e) GWsetheap((char far *)b, e)
#define heapstatus(d) GWheapstatus(d)
#define heap_avail() GWheap_avail()
#define heap_used() GWheap_used()
/* Standard library replacements */
void far *GWmalloc(unsigned long size);
void far *GWcalloc(unsigned long nitems, unsigned long size);
void far *GWrealloc(void far *p, unsigned long size);
void GWfree(void far *p);
#define malloc(s) GWmalloc((unsigned long)s)
#define farmalloc(s) GWmalloc(s)
#define calloc(n,s) GWcalloc((unsigned long)n,(unsigned long)s)
#define farcalloc(n,s) GWcalloc(n, s)
#define realloc(p,s) GWrealloc((void far *)p,(unsigned long)s)
#define farrealloc(p,s) GWrealloc(p, s)
#define free(p) GWfree((void far *)p)
#define farfree(p) GWfree(p)
#else
#include <malloc.h>
#define setheap(b, e)
#define heapstatus(d) fprintf(stderr, "Using system heap; no status available\n")
#define heap_avail()
#define heap_used()
#endif
#endif