@@ -191,6 +191,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
191191 return NULL ;
192192 }
193193 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
194196 return add_metadata_and_align (ptr , size , alignment );
195197 }
196198
@@ -203,6 +205,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
203205 return NULL ;
204206 }
205207 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
206210 return add_metadata_and_align (ptr , size , alignment );
207211 }
208212
@@ -231,13 +235,17 @@ void umf_ba_global_free(void *ptr) {
231235 int ac_index = size_to_idx (total_size );
232236 if (ac_index >= NUM_ALLOCATION_CLASSES ) {
233237 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
234240 ba_os_free (ptr , total_size );
235241 return ;
236242 }
237243
238244 if (!BASE_ALLOC .ac [ac_index ]) {
239245 // if creating ac failed, memory must have been allocated by os
240246 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
241249 ba_os_free (ptr , total_size );
242250 return ;
243251 }
0 commit comments