aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/almalloc.cpp15
-rw-r--r--common/almalloc.h19
2 files changed, 7 insertions, 27 deletions
diff --git a/common/almalloc.cpp b/common/almalloc.cpp
deleted file mode 100644
index 2249b988..00000000
--- a/common/almalloc.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#include "config.h"
-
-#include "almalloc.h"
-
-#include <new>
-#include <cstring>
-
-
-gsl::owner<void*> al_calloc(size_t alignment, size_t size)
-{
- gsl::owner<void*> ret{::operator new[](size, std::align_val_t{alignment}, std::nothrow)};
- if(ret) std::memset(ret, 0, size);
- return ret;
-}
diff --git a/common/almalloc.h b/common/almalloc.h
index a03a0f43..3b9965e6 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -17,11 +17,6 @@ namespace gsl {
template<typename T> using owner = T;
};
-inline void al_free(size_t alignment, gsl::owner<void*> ptr) noexcept
-{ ::operator delete[](ptr, std::align_val_t{alignment}); }
-[[gnu::alloc_align(1), gnu::alloc_size(2), gnu::malloc]]
-gsl::owner<void*> al_calloc(size_t alignment, size_t size);
-
#define DISABLE_ALLOC \
void *operator new(size_t) = delete; \
@@ -61,18 +56,18 @@ struct allocator {
static constexpr auto Alignment = std::max(AlignV, alignof(T));
static constexpr auto AlignVal = std::align_val_t{Alignment};
- using value_type = T;
- using reference = T&;
- using const_reference = const T&;
- using pointer = T*;
- using const_pointer = const T*;
+ using value_type = std::remove_cv_t<std::remove_reference_t<T>>;
+ using reference = value_type&;
+ using const_reference = const value_type&;
+ using pointer = value_type*;
+ using const_pointer = const value_type*;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using is_always_equal = std::true_type;
- template<typename U>
+ template<typename U, std::enable_if_t<alignof(U) <= Alignment,bool> = true>
struct rebind {
- using other = std::enable_if_t<alignof(U) <= Alignment, allocator<U,Alignment>>;
+ using other = allocator<U,Alignment>;
};
constexpr explicit allocator() noexcept = default;