58
58
#include <stddef.h>
59
59
60
60
#include "base_alloc.h"
61
- #include "base_alloc_linear .h"
61
+ #include "base_alloc_global .h"
62
62
#include "critnib.h"
63
63
#include "utils_common.h"
64
64
#include "utils_concurrency.h"
@@ -130,7 +130,6 @@ struct critnib {
130
130
131
131
struct os_mutex_t mutex ; /* writes/removes */
132
132
133
- umf_ba_linear_pool_t * pool_linear ;
134
133
umf_ba_pool_t * pool_nodes ;
135
134
umf_ba_pool_t * pool_leaves ;
136
135
};
@@ -182,23 +181,14 @@ static inline unsigned slice_index(word key, sh_t shift) {
182
181
* critnib_new -- allocates a new critnib structure
183
182
*/
184
183
struct critnib * critnib_new (void ) {
185
- umf_ba_linear_pool_t * pool_linear =
186
- umf_ba_linear_create (0 /* minimal pool size */ );
187
- if (!pool_linear ) {
188
- return NULL ;
189
- }
190
-
191
- struct critnib * c =
192
- umf_ba_linear_alloc (pool_linear , sizeof (struct critnib ));
184
+ struct critnib * c = umf_ba_global_alloc (sizeof (struct critnib ));
193
185
if (!c ) {
194
- goto err_destroy_pool_linear ;
186
+ return NULL ;
195
187
}
196
188
197
- c -> pool_linear = pool_linear ;
198
-
199
189
void * mutex_ptr = util_mutex_init (& c -> mutex );
200
190
if (!mutex_ptr ) {
201
- goto err_destroy_pool_linear ;
191
+ goto err_free_critnib ;
202
192
}
203
193
204
194
c -> pool_nodes = umf_ba_create (sizeof (struct critnib_node ));
@@ -220,8 +210,8 @@ struct critnib *critnib_new(void) {
220
210
umf_ba_destroy (c -> pool_nodes );
221
211
err_util_mutex_destroy :
222
212
util_mutex_destroy_not_free (& c -> mutex );
223
- err_destroy_pool_linear :
224
- umf_ba_linear_destroy ( pool_linear ); // free all its allocations and destroy
213
+ err_free_critnib :
214
+ umf_ba_global_free ( c , sizeof ( struct critnib ));
225
215
return NULL ;
226
216
}
227
217
@@ -272,10 +262,7 @@ void critnib_delete(struct critnib *c) {
272
262
273
263
umf_ba_destroy (c -> pool_nodes );
274
264
umf_ba_destroy (c -> pool_leaves );
275
- umf_ba_linear_destroy (
276
- c -> pool_linear ); // free all its allocations and destroy
277
-
278
- // 'c' was freed in umf_ba_linear_destroy(c->pool_linear)
265
+ umf_ba_global_free (c , sizeof (struct critnib ));
279
266
}
280
267
281
268
/*
0 commit comments