@@ -191,6 +191,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
191
191
return NULL ;
192
192
}
193
193
VALGRIND_DO_MALLOCLIKE_BLOCK (ptr , size , 0 , 0 );
194
+ // utils_annotate_memory_undefined(ptr, size); is redundant here,
195
+ // as mmap() in ba_os_alloc() already marked the memory as undefined
194
196
return add_metadata_and_align (ptr , size , alignment );
195
197
}
196
198
@@ -203,6 +205,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
203
205
return NULL ;
204
206
}
205
207
VALGRIND_DO_MALLOCLIKE_BLOCK (ptr , size , 0 , 0 );
208
+ // utils_annotate_memory_undefined(ptr, size); is redundant here,
209
+ // as mmap() in ba_os_alloc() already marked the memory as undefined
206
210
return add_metadata_and_align (ptr , size , alignment );
207
211
}
208
212
@@ -231,13 +235,17 @@ void umf_ba_global_free(void *ptr) {
231
235
int ac_index = size_to_idx (total_size );
232
236
if (ac_index >= NUM_ALLOCATION_CLASSES ) {
233
237
VALGRIND_DO_FREELIKE_BLOCK (ptr , 0 );
238
+ // utils_annotate_memory_inaccessible(ptr, total_size); is redundant here,
239
+ // as munmap() in ba_os_free() will make it inaccessible anyway
234
240
ba_os_free (ptr , total_size );
235
241
return ;
236
242
}
237
243
238
244
if (!BASE_ALLOC .ac [ac_index ]) {
239
245
// if creating ac failed, memory must have been allocated by os
240
246
VALGRIND_DO_FREELIKE_BLOCK (ptr , 0 );
247
+ // utils_annotate_memory_inaccessible(ptr, total_size); is redundant here,
248
+ // as munmap() in ba_os_free() will make it inaccessible anyway
241
249
ba_os_free (ptr , total_size );
242
250
return ;
243
251
}
0 commit comments