[libc-commits] [libc] [libc] Add aligned_alloc (PR #96586)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Wed Jun 26 09:17:53 PDT 2024


================
@@ -111,6 +113,22 @@ bool FreeList<NUM_BUCKETS>::add_chunk(span<cpp::byte> chunk) {
   return true;
 }
 
+template <size_t NUM_BUCKETS>
+template <typename Cond>
+span<cpp::byte> FreeList<NUM_BUCKETS>::find_chunk_if(Cond op) const {
+  for (FreeListNode *node : chunks_) {
+    while (node != nullptr) {
+      span<cpp::byte> chunk(reinterpret_cast<cpp::byte *>(node), node->size);
----------------
nickdesaulniers wrote:

block.h has:

```
61 using ByteSpan = cpp::span<LIBC_NAMESPACE::cpp::byte>;
```

Perhaps useful to do that in libc/src/__support/freelist.h too. Or add more `using` statements, here and in the other headers.  Isn't `using` in a header frowned upon though, since TU's that include that header get those using statements?  Would be happy to remove them (in another, distinct PR).

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


More information about the libc-commits mailing list