From 7f9a822cdf3b03bd3e5ee0c86fe2d00300b860bd Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Tue, 24 Mar 2026 20:06:50 -0400 Subject: [PATCH 1/5] expose c23 free_sized/free_aligned_sized --- src/snmalloc/global/libc.h | 5 +++++ src/snmalloc/override/malloc.cc | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/snmalloc/global/libc.h b/src/snmalloc/global/libc.h index 99df44617..9b8209fe7 100644 --- a/src/snmalloc/global/libc.h +++ b/src/snmalloc/global/libc.h @@ -39,6 +39,11 @@ namespace snmalloc::libc dealloc(ptr, size); } + SNMALLOC_FAST_PATH_INLINE void free_aligned_sized(void* ptr, size_t alignment, size_t size) + { + dealloc(ptr, alignment, size); + } + SNMALLOC_FAST_PATH_INLINE void* calloc(size_t nmemb, size_t size) { bool overflow = false; diff --git a/src/snmalloc/override/malloc.cc b/src/snmalloc/override/malloc.cc index 267546785..210e040ec 100644 --- a/src/snmalloc/override/malloc.cc +++ b/src/snmalloc/override/malloc.cc @@ -23,6 +23,18 @@ extern "C" snmalloc::libc::free(ptr); } + SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(free_sized)( + void* ptr, size_t size) + { + snmalloc::libc::free_sized(ptr, size); + } + + SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(free_aligned_sized)( + void* ptr, size_t alignment, size_t size) + { + snmalloc::libc::free_aligned_sized(ptr, alignment, size); + } + SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(cfree)(void* ptr) { snmalloc::libc::free(ptr); From 8270c8b346a2d2dcb305702c648f4a4638c59d8c Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Wed, 25 Mar 2026 13:39:56 -0400 Subject: [PATCH 2/5] fix align/size ordering --- src/snmalloc/global/libc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snmalloc/global/libc.h b/src/snmalloc/global/libc.h index 9b8209fe7..6d68d6c51 100644 --- a/src/snmalloc/global/libc.h +++ b/src/snmalloc/global/libc.h @@ -41,7 +41,7 @@ namespace snmalloc::libc SNMALLOC_FAST_PATH_INLINE void free_aligned_sized(void* ptr, size_t alignment, size_t size) { - dealloc(ptr, alignment, size); + dealloc(ptr, size, alignment); } SNMALLOC_FAST_PATH_INLINE void* calloc(size_t nmemb, size_t size) From fe402f3c47761bcc73f0509c75629cab81c292c6 Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Fri, 27 Mar 2026 10:41:42 -0400 Subject: [PATCH 3/5] Fix format check --- src/snmalloc/global/libc.h | 3 ++- src/snmalloc/override/malloc.cc | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/snmalloc/global/libc.h b/src/snmalloc/global/libc.h index 6d68d6c51..3ab215c3b 100644 --- a/src/snmalloc/global/libc.h +++ b/src/snmalloc/global/libc.h @@ -39,7 +39,8 @@ namespace snmalloc::libc dealloc(ptr, size); } - SNMALLOC_FAST_PATH_INLINE void free_aligned_sized(void* ptr, size_t alignment, size_t size) + SNMALLOC_FAST_PATH_INLINE void free_aligned_sized( + void* ptr, size_t alignment, size_t size) { dealloc(ptr, size, alignment); } diff --git a/src/snmalloc/override/malloc.cc b/src/snmalloc/override/malloc.cc index 210e040ec..cf949680d 100644 --- a/src/snmalloc/override/malloc.cc +++ b/src/snmalloc/override/malloc.cc @@ -23,8 +23,7 @@ extern "C" snmalloc::libc::free(ptr); } - SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(free_sized)( - void* ptr, size_t size) + SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(free_sized)(void* ptr, size_t size) { snmalloc::libc::free_sized(ptr, size); } From ea34ac2f769f166a6ff2afac9409a8c7c6615103 Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Fri, 27 Mar 2026 11:06:56 -0400 Subject: [PATCH 4/5] Restore format diff output in CI --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 072755e95..237e5a749 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -373,7 +373,10 @@ jobs: # Run the clang-format check and error if it generates a diff - name: Run clang-format working-directory: ${{github.workspace}}/build - run: make clangformat-check + run: | + set -eo pipefail + make clangformat + git diff --exit-code - name: Run clang-tidy run: | clang-tidy-15 src/snmalloc/override/malloc.cc -header-filter="`pwd`/*" -warnings-as-errors='*' -export-fixes=tidy.fail -- -std=c++17 -mcx16 -DSNMALLOC_USE_WAIT_ON_ADDRESS=1 -DSNMALLOC_PLATFORM_HAS_GETENTROPY=0 -Isrc From ebcddcfa7c2f496e3ccee46b3102cbc2a3b63df8 Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Fri, 27 Mar 2026 11:09:19 -0400 Subject: [PATCH 5/5] Apply CI format patch --- src/snmalloc/global/libc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snmalloc/global/libc.h b/src/snmalloc/global/libc.h index 3ab215c3b..726f61190 100644 --- a/src/snmalloc/global/libc.h +++ b/src/snmalloc/global/libc.h @@ -39,8 +39,8 @@ namespace snmalloc::libc dealloc(ptr, size); } - SNMALLOC_FAST_PATH_INLINE void free_aligned_sized( - void* ptr, size_t alignment, size_t size) + SNMALLOC_FAST_PATH_INLINE void + free_aligned_sized(void* ptr, size_t alignment, size_t size) { dealloc(ptr, size, alignment); }