Skip to content

Commit 70c33d0

Browse files
authored
Merge pull request #1404 from ldorau/Add_missing_utils_annotate_memory_inaccessible
Add comments about redundant annotations
2 parents 7d4e12b + f1344d3 commit 70c33d0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/base_alloc/base_alloc_global.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)