[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 12:05:25 PST 2025


================
@@ -355,93 +346,84 @@ TEST(LlvmLibcBlockTest, CanGetConstBlockFromUsableSpace) {
   EXPECT_EQ(block1, block2);
 }
 
-TEST(LlvmLibcBlockTest, CanAllocate) {
-  constexpr size_t kN = 1024 + Block::BLOCK_OVERHEAD;
-
+TEST(LlvmLibcBlockTest, Allocate) {
   // Ensure we can allocate everything up to the block size within this block.
-  for (size_t i = 0; i < kN - 2 * Block::BLOCK_OVERHEAD; ++i) {
-    alignas(Block::ALIGNMENT) array<byte, kN> bytes{};
+  for (size_t i = 0; i < 1024; ++i) {
----------------
PiJoules wrote:

nit: Could you keep the `1024` as a variable to indicate this is the buffer size rather than have magic numbers.

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


More information about the libc-commits mailing list