2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 /* This code is in the public domain.
13 ** Version: 1.1 Author: Walt Karas
16 /* External header file for Heap Memory Manager. See documentation in
22 /* Include once per configuration in a particular translation unit. */
26 /* Default configuration. */
28 #ifndef HMM_INC_CNFG_DFLT
29 #define HMM_INC_CNFG_DFLT
33 #elif HMM_CNFG_NUM == 0
35 /* Test configuration. */
37 #ifndef HMM_INC_CNFG_0
38 #define HMM_INC_CNFG_0
42 #elif HMM_CNFG_NUM == 1
44 #ifndef HMM_INC_CNFG_1
45 #define HMM_INC_CNFG_1
49 #elif HMM_CNFG_NUM == 2
51 #ifndef HMM_INC_CNFG_2
52 #define HMM_INC_CNFG_2
56 #elif HMM_CNFG_NUM == 3
58 #ifndef HMM_INC_CNFG_3
59 #define HMM_INC_CNFG_3
63 #elif HMM_CNFG_NUM == 4
65 #ifndef HMM_INC_CNFG_4
66 #define HMM_INC_CNFG_4
70 #elif HMM_CNFG_NUM == 5
72 #ifndef HMM_INC_CNFG_5
73 #define HMM_INC_CNFG_5
83 /* Heap descriptor. */
84 typedef struct HMM_UNIQUE(structure
)
88 /* Pointer to (payload of) root node in AVL tree. This field should
89 ** really be the AVL tree descriptor (type avl_avl). But (in the
90 ** instantiation of the AVL tree generic package used in package) the
91 ** AVL tree descriptor simply contains a pointer to the root. So,
92 ** whenever a pointer to the AVL tree descriptor is needed, I use the
95 ** (avl_avl *) &(heap_desc->avl_tree_root)
97 ** (where heap_desc is a pointer to a heap descriptor). This trick
98 ** allows me to avoid including cavl_if.h in this external header. */
101 /* Pointer to first byte of last block freed, after any coalescing. */
106 HMM_UNIQUE(size_bau
) num_baus_can_shrink
;
107 void *end_of_shrinkable_chunk
;
109 HMM_UNIQUE(descriptor
);
111 /* Prototypes for externally-callable functions. */
113 void HMM_UNIQUE(init
)(HMM_UNIQUE(descriptor
) *desc
);
115 void *HMM_UNIQUE(alloc
)(
116 HMM_UNIQUE(descriptor
) *desc
, HMM_UNIQUE(size_aau
) num_addr_align_units
);
118 /* NOT YET IMPLEMENTED */
119 void *HMM_UNIQUE(greedy_alloc
)(
120 HMM_UNIQUE(descriptor
) *desc
, HMM_UNIQUE(size_aau
) needed_addr_align_units
,
121 HMM_UNIQUE(size_aau
) coveted_addr_align_units
);
123 int HMM_UNIQUE(resize
)(
124 HMM_UNIQUE(descriptor
) *desc
, void *mem
,
125 HMM_UNIQUE(size_aau
) num_addr_align_units
);
127 /* NOT YET IMPLEMENTED */
128 int HMM_UNIQUE(greedy_resize
)(
129 HMM_UNIQUE(descriptor
) *desc
, void *mem
,
130 HMM_UNIQUE(size_aau
) needed_addr_align_units
,
131 HMM_UNIQUE(size_aau
) coveted_addr_align_units
);
133 void HMM_UNIQUE(free
)(HMM_UNIQUE(descriptor
) *desc
, void *mem
);
135 HMM_UNIQUE(size_aau
) HMM_UNIQUE(true_size
)(void *mem
);
137 HMM_UNIQUE(size_aau
) HMM_UNIQUE(largest_available
)(
138 HMM_UNIQUE(descriptor
) *desc
);
140 void HMM_UNIQUE(new_chunk
)(
141 HMM_UNIQUE(descriptor
) *desc
, void *start_of_chunk
,
142 HMM_UNIQUE(size_bau
) num_block_align_units
);
144 void HMM_UNIQUE(grow_chunk
)(
145 HMM_UNIQUE(descriptor
) *desc
, void *end_of_chunk
,
146 HMM_UNIQUE(size_bau
) num_block_align_units
);
148 /* NOT YET IMPLEMENTED */
149 void HMM_UNIQUE(shrink_chunk
)(
150 HMM_UNIQUE(descriptor
) *desc
,
151 HMM_UNIQUE(size_bau
) num_block_align_units
);
153 #endif /* defined HMM_PROCESS */