Skip to content

Commit a7f1d83

Browse files
committed
Changes
1 parent 957d45e commit a7f1d83

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/critnib/critnib.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void free_leaf(struct critnib *__restrict c,
288288
return;
289289
}
290290

291-
if (c->cb_free_leaf && k) {
291+
if (c->cb_free_leaf && k && k->value) {
292292
c->cb_free_leaf(c->leaf_allocator, (void *)k->value);
293293
}
294294

@@ -370,6 +370,10 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) {
370370
word at = path ^ key;
371371
if (!at) {
372372
ASSERT(is_leaf(n));
373+
if (to_leaf(kn)->value == value) {
374+
// do not free the value
375+
to_leaf(kn)->value = NULL;
376+
}
373377
free_leaf(c, to_leaf(kn));
374378

375379
if (update) {

src/provider/provider_tracking.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ static umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) {
709709
"size=%zu, ret = %d",
710710
ptr, size, ret);
711711
}
712-
umf_ba_global_free(value);
713712
}
714713

715714
ret = umfMemoryProviderFree(p->hUpstream, ptr, size);
@@ -1110,14 +1109,12 @@ umf_memory_provider_ops_t UMF_TRACKING_MEMORY_PROVIDER_OPS = {
11101109
.ipc.open_ipc_handle = trackingOpenIpcHandle,
11111110
.ipc.close_ipc_handle = trackingCloseIpcHandle};
11121111

1113-
/*
11141112
static void free_ipc_cache_value(void *unused, void *ipc_cache_value) {
11151113
(void)unused;
11161114
if (ipc_cache_value) {
11171115
umf_ba_global_free(ipc_cache_value);
11181116
}
11191117
}
1120-
*/
11211118

11221119
umf_result_t umfTrackingMemoryProviderCreate(
11231120
umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool,
@@ -1131,8 +1128,7 @@ umf_result_t umfTrackingMemoryProviderCreate(
11311128
return UMF_RESULT_ERROR_UNKNOWN;
11321129
}
11331130
params.pool = hPool;
1134-
// params.ipcCache = critnib_new(free_ipc_cache_value, NULL);
1135-
params.ipcCache = critnib_new(NULL, NULL);
1131+
params.ipcCache = critnib_new(free_ipc_cache_value, NULL);
11361132
if (!params.ipcCache) {
11371133
LOG_ERR("failed to create IPC cache");
11381134
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;

0 commit comments

Comments
 (0)