Release 940405
[wine/gsoc-2012-control.git] / include / heap.h
blob94ba9c95667b4dffac882a4d973664c9a18954dc
1 /* $Id: heap.h,v 1.2 1993/07/04 04:04:21 root Exp root $
2 */
3 /*
4 * Copyright Robert J. Amstadt, 1993
5 */
6 #ifndef HEAP_H
7 #define HEAP_H
9 #include "segmem.h"
10 #include "regfunc.h"
11 #include "atom.h"
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;
20 unsigned char lock;
21 unsigned char flags;
22 } MDESC;
24 typedef struct heap_local_heap_s
26 struct heap_local_heap_s *next;
27 MDESC *free_list;
28 ATOMTABLE *local_table;
29 unsigned short selector;
30 } LHEAP;
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
48 * death.
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;
66 short sequence;
67 void *addr;
68 int length;
69 int lock_count;
70 void *linear_addr;
71 int linear_key;
72 int linear_count;
73 } GDESC;
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);
83 #endif /* HEAP_H */