[libcxx-commits] [PATCH] D123511: [libc++abi] Fix fallback allocator alignment issue

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 11 08:31:46 PDT 2022


ldionne added a comment.

Just to confirm my understanding, basically this only triggers when `malloc(...)` returns `nullptr`, i.e. when memory is exhausted, right?



================
Comment at: libcxxabi/src/fallback_malloc.cpp:76-77
+
+typedef half_size_uint<sizeof(void*)>::type heap_offset;
+typedef half_size_uint<sizeof(void*)>::type heap_size;
 
----------------
This is perhaps silly, but I'm not sure I understand why changing the representation of the offset and size is what we want to do here. Shouldn't we instead be adjusting the pointer we are returning when we allocate memory to have the proper alignment?

In other words, this patch has the side effect that we'll return properly aligned memory, however we could technically keep the same representation as before and also return aligned memory, right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123511/new/

https://reviews.llvm.org/D123511



More information about the libcxx-commits mailing list