Release 940518
[wine/multimedia.git] / include / heap.h
blob22fe1294132bc7a8a534d499a9c31df83c504181
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; /* Next GDESC in list */
64 struct global_mem_desc_s *prev; /* Previous GDESC in list */
65 unsigned short handle; /* Handle of this block. */
66 short sequence; /* Block sequence # in huge block */
67 void *addr; /* Address allocated with mmap() */
68 int length; /* Length of block */
69 int lock_count; /* Block lock count */
70 unsigned short alias; /* Offset-zero alias selector */
71 unsigned int alias_key; /* Offset-zero alias sh. mem. key */
72 void *linear_addr; /* Linear address of huge block */
73 int linear_key; /* Linear shared memory key */
74 int linear_count; /* Linear lock count */
75 } GDESC;
77 extern GDESC *GlobalList;
79 extern void *GlobalQuickAlloc(int size);
80 extern unsigned int GlobalHandleFromPointer(void *block);
81 extern GDESC *GlobalGetGDesc(unsigned int block);
82 extern void *GlobalLinearLock(unsigned int block);
83 extern unsigned int GlobalLinearUnlock(unsigned int block);
85 #endif /* HEAP_H */