@@ -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 );
@@ -1116,6 +1109,13 @@ umf_memory_provider_ops_t UMF_TRACKING_MEMORY_PROVIDER_OPS = {
1116
1109
.ipc .open_ipc_handle = trackingOpenIpcHandle ,
1117
1110
.ipc .close_ipc_handle = trackingCloseIpcHandle };
1118
1111
1112
+ static void free_ipc_cache_value (void * unused , void * ipc_cache_value ) {
1113
+ (void )unused ;
1114
+ if (ipc_cache_value ) {
1115
+ umf_ba_global_free (ipc_cache_value );
1116
+ }
1117
+ }
1118
+
1119
1119
umf_result_t umfTrackingMemoryProviderCreate (
1120
1120
umf_memory_provider_handle_t hUpstream , umf_memory_pool_handle_t hPool ,
1121
1121
umf_memory_provider_handle_t * hTrackingProvider ) {
@@ -1128,7 +1128,7 @@ umf_result_t umfTrackingMemoryProviderCreate(
1128
1128
return UMF_RESULT_ERROR_UNKNOWN ;
1129
1129
}
1130
1130
params .pool = hPool ;
1131
- params .ipcCache = critnib_new (NULL , NULL );
1131
+ params .ipcCache = critnib_new (free_ipc_cache_value , NULL );
1132
1132
if (!params .ipcCache ) {
1133
1133
LOG_ERR ("failed to create IPC cache" );
1134
1134
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
@@ -1156,6 +1156,18 @@ void umfTrackingMemoryProviderGetUpstreamProvider(
1156
1156
* hUpstream = p -> hUpstream ;
1157
1157
}
1158
1158
1159
+ static void free_leaf (void * leaf_allocator , void * ptr ) {
1160
+ if (ptr ) {
1161
+ umf_ba_free (leaf_allocator , ptr );
1162
+ }
1163
+ }
1164
+
1165
+ static void free_ipc_segment (void * ipc_info_allocator , void * ptr ) {
1166
+ if (ptr ) {
1167
+ umf_ba_free (ipc_info_allocator , ptr );
1168
+ }
1169
+ }
1170
+
1159
1171
umf_memory_tracker_handle_t umfMemoryTrackerCreate (void ) {
1160
1172
umf_memory_tracker_handle_t handle =
1161
1173
umf_ba_global_alloc (sizeof (struct umf_memory_tracker_t ));
@@ -1180,7 +1192,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1180
1192
1181
1193
int i ;
1182
1194
for (i = 0 ; i < MAX_LEVELS_OF_ALLOC_SEGMENT_MAP ; i ++ ) {
1183
- handle -> alloc_segments_map [i ] = critnib_new (NULL , NULL );
1195
+ handle -> alloc_segments_map [i ] =
1196
+ critnib_new (free_leaf , alloc_info_allocator );
1184
1197
if (!handle -> alloc_segments_map [i ]) {
1185
1198
goto err_destroy_alloc_segments_map ;
1186
1199
}
@@ -1192,7 +1205,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1192
1205
goto err_destroy_alloc_segments_map ;
1193
1206
}
1194
1207
1195
- handle -> ipc_segments_map = critnib_new (NULL , NULL );
1208
+ handle -> ipc_segments_map =
1209
+ critnib_new (free_ipc_segment , handle -> ipc_info_allocator );
1196
1210
if (!handle -> ipc_segments_map ) {
1197
1211
goto err_destroy_ipc_info_allocator ;
1198
1212
}
0 commit comments