From b19d27ef6ce3bd49cdd03cca511b88b7cb82bbd8 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 13 Jan 2025 11:42:20 -0800 Subject: [PATCH] replace posix_memalign with aligned_alloc We can do this now that C++17 is available. Signed-off-by: Rosen Penev --- configure.ac | 2 -- rak/allocators.h | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index b898eaac3..bd081acb6 100644 --- a/configure.ac +++ b/configure.ac @@ -87,8 +87,6 @@ LIBS="$PTHREAD_LIBS $ZLIB_LIBS $LIBS" TORRENT_ARG_OPENSSL TORRENT_ARG_CYRUS_RC4 -AC_CHECK_FUNCS(posix_memalign) - TORRENT_CHECK_MADVISE TORRENT_CHECK_CACHELINE TORRENT_CHECK_POPCOUNT diff --git a/rak/allocators.h b/rak/allocators.h index 0398aa7ee..73d77a86a 100644 --- a/rak/allocators.h +++ b/rak/allocators.h @@ -76,10 +76,7 @@ class cacheline_allocator { pointer allocate(size_type num, const_void_pointer hint = 0) { return alloc_size(num*sizeof(T)); } static pointer alloc_size(size_type size) { - pointer ptr = NULL; - [[maybe_unused]] int result = posix_memalign((void**)&ptr, LT_SMP_CACHE_BYTES, size); - - return ptr; + return static_cast(std::aligned_alloc(LT_SMP_CACHE_BYTES, size)); } void construct (pointer p, const T& value) { new((void*)p)T(value); }