[libc-commits] [libc] [libc] Fix malloc Block alignment issue on riscv32 (PR #117815)

via libc-commits libc-commits at lists.llvm.org
Tue Jan 14 11:55:55 PST 2025


================
@@ -309,21 +322,30 @@ class Block {
     Block *next;
   };
 
-  // Divide a block into up to 3 blocks according to `BlockInfo`. This should
-  // only be called if `can_allocate` returns true.
+  // Divide a block into up to 3 blocks according to `BlockInfo`. Behavior is
+  // undefined if allocation is not possible for the given size and alignment.
   static BlockInfo allocate(Block *block, size_t alignment, size_t size);
 
+  LIBC_INLINE static uintptr_t next_possible_block_start(
+      uintptr_t ptr, size_t usable_space_alignment = alignof(max_align_t)) {
+    return align_up(ptr + sizeof(Block), usable_space_alignment) -
----------------
PiJoules wrote:

Feel free to disregard this since this is probably me nitpicking on potential overflows.

https://github.com/llvm/llvm-project/pull/117815


More information about the libc-commits mailing list