Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/base_alloc/base_alloc_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
return NULL;
}
VALGRIND_DO_MALLOCLIKE_BLOCK(ptr, size, 0, 0);
// utils_annotate_memory_undefined(ptr, size); is redundant here,
// as mmap() in ba_os_alloc() already marked the memory as undefined
return add_metadata_and_align(ptr, size, alignment);
}

Expand All @@ -203,6 +205,8 @@ void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
return NULL;
}
VALGRIND_DO_MALLOCLIKE_BLOCK(ptr, size, 0, 0);
// utils_annotate_memory_undefined(ptr, size); is redundant here,
// as mmap() in ba_os_alloc() already marked the memory as undefined
return add_metadata_and_align(ptr, size, alignment);
}

Expand Down Expand Up @@ -231,13 +235,17 @@ void umf_ba_global_free(void *ptr) {
int ac_index = size_to_idx(total_size);
if (ac_index >= NUM_ALLOCATION_CLASSES) {
VALGRIND_DO_FREELIKE_BLOCK(ptr, 0);
// utils_annotate_memory_inaccessible(ptr, total_size); is redundant here,
// as munmap() in ba_os_free() will make it inaccessible anyway
ba_os_free(ptr, total_size);
return;
}

if (!BASE_ALLOC.ac[ac_index]) {
// if creating ac failed, memory must have been allocated by os
VALGRIND_DO_FREELIKE_BLOCK(ptr, 0);
// utils_annotate_memory_inaccessible(ptr, total_size); is redundant here,
// as munmap() in ba_os_free() will make it inaccessible anyway
ba_os_free(ptr, total_size);
return;
}
Expand Down
Loading