Release 940912
[wine/gsoc-2012-control.git] / include / heap.h
blob7ff97a09c1bcf77b77b9bdfd77af4e246dbc8f59
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 unsigned short delta; /* Number saved for Windows compat. */
31 } LHEAP;
33 extern void HEAP_Init(MDESC **free_list, void *start, int length);
34 extern void *HEAP_Alloc(MDESC **free_list, int flags, int bytes);
35 extern int HEAP_Free(MDESC **free_list, void *block);
36 extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block,
37 int new_size, unsigned int flags);
38 extern LHEAP *HEAP_LocalFindHeap(unsigned short owner);
39 extern unsigned int HEAP_LocalSize(MDESC **free_list, unsigned int handle);
41 #define HEAP_OWNER (Segments[Stack16Frame[11] >> 3].owner)
42 #define LOCALHEAP() (&HEAP_LocalFindHeap(HEAP_OWNER)->free_list)
43 #define LOCALATOMTABLE() (&HEAP_LocalFindHeap(HEAP_OWNER)->local_table)
45 /**********************************************************************
46 * GLOBAL HEAP STRUCTURES AND FUNCTIONS:
48 * Global memory pool descriptor. Segments MUST be maintained in segment
49 * ascending order. If not the reallocation routine will die a horrible
50 * death.
52 * handle = 0, this descriptor contains the address of a free pool.
53 * != 0, this describes an allocated block.
55 * sequence = 0, this is not a huge block
56 * > 0, this is a portion of a huge block
57 * =-1, this is a free segment
59 * addr - address of this memory block.
61 * length - used to maintain huge blocks.
63 typedef struct global_mem_desc_s
65 struct global_mem_desc_s *next; /* Next GDESC in list */
66 struct global_mem_desc_s *prev; /* Previous GDESC in list */
67 unsigned short handle; /* Handle of this block. */
68 short sequence; /* Block sequence # in huge block */
69 void *addr; /* Address allocated with mmap() */
70 int length; /* Length of block */
71 int lock_count; /* Block lock count */
72 unsigned short alias; /* Offset-zero alias selector */
73 unsigned int alias_key; /* Offset-zero alias sh. mem. key */
74 void *linear_addr; /* Linear address of huge block */
75 int linear_key; /* Linear shared memory key */
76 int linear_count; /* Linear lock count */
77 } GDESC;
79 extern GDESC *GlobalList;
81 extern void *GlobalQuickAlloc(int size);
82 extern unsigned int GlobalHandleFromPointer(void *block);
83 extern GDESC *GlobalGetGDesc(unsigned int block);
84 extern void *GlobalLinearLock(unsigned int block);
85 extern unsigned int GlobalLinearUnlock(unsigned int block);
87 #endif /* HEAP_H */