@@ -271,8 +271,6 @@ static umf_result_t umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker,
271
271
parent_value -> n_children -- ;
272
272
}
273
273
274
- umf_ba_free (hTracker -> alloc_info_allocator , value );
275
-
276
274
return UMF_RESULT_SUCCESS ;
277
275
}
278
276
@@ -339,8 +337,6 @@ umfMemoryTrackerRemoveIpcSegment(umf_memory_tracker_handle_t hTracker,
339
337
(void * )hTracker , ptr , v -> size , (void * )v -> provider ,
340
338
(void * )v -> ipc_cache_value );
341
339
342
- umf_ba_free (hTracker -> ipc_info_allocator , value );
343
-
344
340
return UMF_RESULT_SUCCESS ;
345
341
}
346
342
@@ -664,8 +660,6 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
664
660
lowLevel , lowPtr , lowValue -> n_children , highPtr ,
665
661
highValue -> n_children , totalSize );
666
662
667
- umf_ba_free (provider -> hTracker -> alloc_info_allocator , highValue );
668
-
669
663
return UMF_RESULT_SUCCESS ;
670
664
671
665
err_fatal :
@@ -715,7 +709,6 @@ static umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) {
715
709
"size=%zu, ret = %d" ,
716
710
ptr , size , ret );
717
711
}
718
- umf_ba_global_free (value );
719
712
}
720
713
721
714
ret = umfMemoryProviderFree (p -> hUpstream , ptr , size );
@@ -1119,6 +1112,13 @@ umf_memory_provider_ops_t UMF_TRACKING_MEMORY_PROVIDER_OPS = {
1119
1112
.ipc .open_ipc_handle = trackingOpenIpcHandle ,
1120
1113
.ipc .close_ipc_handle = trackingCloseIpcHandle };
1121
1114
1115
+ static void free_ipc_cache_value (void * unused , void * ipc_cache_value ) {
1116
+ (void )unused ;
1117
+ if (ipc_cache_value ) {
1118
+ umf_ba_global_free (ipc_cache_value );
1119
+ }
1120
+ }
1121
+
1122
1122
umf_result_t umfTrackingMemoryProviderCreate (
1123
1123
umf_memory_provider_handle_t hUpstream , umf_memory_pool_handle_t hPool ,
1124
1124
umf_memory_provider_handle_t * hTrackingProvider ) {
@@ -1131,7 +1131,7 @@ umf_result_t umfTrackingMemoryProviderCreate(
1131
1131
return UMF_RESULT_ERROR_UNKNOWN ;
1132
1132
}
1133
1133
params .pool = hPool ;
1134
- params .ipcCache = critnib_new (NULL , NULL );
1134
+ params .ipcCache = critnib_new (free_ipc_cache_value , NULL );
1135
1135
if (!params .ipcCache ) {
1136
1136
LOG_ERR ("failed to create IPC cache" );
1137
1137
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
@@ -1159,6 +1159,18 @@ void umfTrackingMemoryProviderGetUpstreamProvider(
1159
1159
* hUpstream = p -> hUpstream ;
1160
1160
}
1161
1161
1162
+ static void free_leaf (void * leaf_allocator , void * ptr ) {
1163
+ if (ptr ) {
1164
+ umf_ba_free (leaf_allocator , ptr );
1165
+ }
1166
+ }
1167
+
1168
+ static void free_ipc_segment (void * ipc_info_allocator , void * ptr ) {
1169
+ if (ptr ) {
1170
+ umf_ba_free (ipc_info_allocator , ptr );
1171
+ }
1172
+ }
1173
+
1162
1174
umf_memory_tracker_handle_t umfMemoryTrackerCreate (void ) {
1163
1175
umf_memory_tracker_handle_t handle =
1164
1176
umf_ba_global_alloc (sizeof (struct umf_memory_tracker_t ));
@@ -1183,7 +1195,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1183
1195
1184
1196
int i ;
1185
1197
for (i = 0 ; i < MAX_LEVELS_OF_ALLOC_SEGMENT_MAP ; i ++ ) {
1186
- handle -> alloc_segments_map [i ] = critnib_new (NULL , NULL );
1198
+ handle -> alloc_segments_map [i ] =
1199
+ critnib_new (free_leaf , alloc_info_allocator );
1187
1200
if (!handle -> alloc_segments_map [i ]) {
1188
1201
goto err_destroy_alloc_segments_map ;
1189
1202
}
@@ -1195,7 +1208,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1195
1208
goto err_destroy_alloc_segments_map ;
1196
1209
}
1197
1210
1198
- handle -> ipc_segments_map = critnib_new (NULL , NULL );
1211
+ handle -> ipc_segments_map =
1212
+ critnib_new (free_ipc_segment , handle -> ipc_info_allocator );
1199
1213
if (!handle -> ipc_segments_map ) {
1200
1214
goto err_destroy_ipc_info_allocator ;
1201
1215
}
0 commit comments