Skip to content

Commit 38e1c83

Browse files
authored
Merge pull request #767 from ldorau/Use_the_UMF_base_allocator_in_RAVL_instead_of_the_glibcs_one
Use the UMF base allocator in RAVL instead of the glibc's one
2 parents 0291a0d + 7e549a6 commit 38e1c83

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ravl/ravl.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "../src/utils/utils_common.h"
1717
#include "../src/utils/utils_concurrency.h"
1818
#include "assert.h"
19+
#include "base_alloc_global.h"
1920

2021
#include <errno.h>
2122
#include <stdint.h>
@@ -51,7 +52,7 @@ struct ravl {
5152
* ravl_new -- creates a new ravl tree instance
5253
*/
5354
struct ravl *ravl_new_sized(ravl_compare *compare, size_t data_size) {
54-
struct ravl *r = malloc(sizeof(*r));
55+
struct ravl *r = umf_ba_global_alloc(sizeof(*r));
5556
if (r == NULL) {
5657
return NULL;
5758
}
@@ -87,7 +88,7 @@ static void ravl_foreach_node(struct ravl_node *n, ravl_cb cb, void *arg,
8788
ravl_foreach_node(n->slots[RAVL_RIGHT], cb, arg, free_node);
8889

8990
if (free_node) {
90-
free(n);
91+
umf_ba_global_free(n);
9192
}
9293
}
9394

@@ -104,7 +105,7 @@ void ravl_clear(struct ravl *ravl) {
104105
*/
105106
void ravl_delete_cb(struct ravl *ravl, ravl_cb cb, void *arg) {
106107
ravl_foreach_node(ravl->root, cb, arg, 1);
107-
free(ravl);
108+
umf_ba_global_free(ravl);
108109
}
109110

110111
/*
@@ -149,7 +150,7 @@ static void ravl_node_copy_constructor(void *data, size_t data_size,
149150
*/
150151
static struct ravl_node *ravl_new_node(struct ravl *ravl, ravl_constr constr,
151152
const void *arg) {
152-
struct ravl_node *n = malloc(sizeof(*n) + ravl->data_size);
153+
struct ravl_node *n = umf_ba_global_alloc(sizeof(*n) + ravl->data_size);
153154
if (n == NULL) {
154155
return NULL;
155156
}
@@ -383,7 +384,7 @@ int ravl_emplace(struct ravl *ravl, ravl_constr constr, const void *arg) {
383384

384385
error_duplicate:
385386
errno = EEXIST;
386-
free(n);
387+
umf_ba_global_free(n);
387388
return -1;
388389
}
389390

@@ -516,7 +517,7 @@ void ravl_remove(struct ravl *ravl, struct ravl_node *n) {
516517
}
517518

518519
*ravl_node_ref(ravl, n) = r;
519-
free(n);
520+
umf_ba_global_free(n);
520521
}
521522
}
522523

0 commit comments

Comments
 (0)