1 /* $Id: heap.h,v 1.2 1993/07/04 04:04:21 root Exp root $
4 * Copyright Robert J. Amstadt, 1993
13 /**********************************************************************
14 * LOCAL HEAP STRUCTURES AND FUNCTIONS
16 typedef struct heap_mem_desc_s
18 struct heap_mem_desc_s
*prev
, *next
;
19 unsigned short length
;
24 typedef struct heap_local_heap_s
26 struct heap_local_heap_s
*next
;
28 ATOMTABLE
*local_table
;
29 unsigned short selector
;
32 extern void HEAP_Init(MDESC
**free_list
, void *start
, int length
);
33 extern void *HEAP_Alloc(MDESC
**free_list
, int flags
, int bytes
);
34 extern int HEAP_Free(MDESC
**free_list
, void *block
);
35 extern void *HEAP_ReAlloc(MDESC
**free_list
, void *old_block
,
36 int new_size
, unsigned int flags
);
37 extern LHEAP
*HEAP_LocalFindHeap(unsigned short owner
);
39 #define HEAP_OWNER (Segments[Stack16Frame[11] >> 3].owner)
40 #define LOCALHEAP() (&HEAP_LocalFindHeap(HEAP_OWNER)->free_list)
41 #define LOCALATOMTABLE() (&HEAP_LocalFindHeap(HEAP_OWNER)->local_table)
43 /**********************************************************************
44 * GLOBAL HEAP STRUCTURES AND FUNCTIONS:
46 * Global memory pool descriptor. Segments MUST be maintained in segment
47 * ascending order. If not the reallocation routine will die a horrible
50 * handle = 0, this descriptor contains the address of a free pool.
51 * != 0, this describes an allocated block.
53 * sequence = 0, this is not a huge block
54 * > 0, this is a portion of a huge block
55 * =-1, this is a free segment
57 * addr - address of this memory block.
59 * length - used to maintain huge blocks.
61 typedef struct global_mem_desc_s
63 struct global_mem_desc_s
*next
;
64 struct global_mem_desc_s
*prev
;
65 unsigned short handle
;
75 extern GDESC
*GlobalList
;
77 extern void *GlobalQuickAlloc(int size
);
78 extern unsigned int GlobalHandleFromPointer(void *block
);
79 extern GDESC
*GlobalGetGDesc(unsigned int block
);
80 extern void *GlobalLinearLock(unsigned int block
);
81 extern unsigned int GlobalLinearUnlock(unsigned int block
);