summaryrefslogtreecommitdiff
path: root/src/memory-allocator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory-allocator.hpp')
-rw-r--r--src/memory-allocator.hpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/memory-allocator.hpp b/src/memory-allocator.hpp
deleted file mode 100644
index c14304a..0000000
--- a/src/memory-allocator.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef PKE_MEMORY_ALLOCATOR_HPP
-#define PKE_MEMORY_ALLOCATOR_HPP
-
-#include "memory.hpp"
-
-template <typename T, std::size_t SZ = DEFAULT_BUCKET_SIZE> class PkeTransAllocator {
-public:
- typedef T value_type;
- MemBucket *transientBucket = nullptr;
-
- PkeTransAllocator() : transientBucket(Pke_BeginTransientBucket(SZ)) {
- }
- ~PkeTransAllocator() {
- Pke_EndTransientBucket(this->transientBucket);
- }
-
- template <class U> struct rebind {typedef PkeTransAllocator<U, SZ> other;};
- template <typename U> explicit PkeTransAllocator(const PkeTransAllocator<U> &other) {
- (void)other;
- }
-
- T *allocate(std::size_t n) {
- auto *ptr = reinterpret_cast<T *>(Pke_New(sizeof(T) * n, this->transientBucket));
- if (ptr) return ptr;
- throw "Pke-Allocator Failed to allocate";
- }
-
- void deallocate(const T *ptr, std::size_t n) {
- Pke_Delete(ptr, sizeof(T) * n, this->transientBucket);
- }
-};
-
-template <typename T> class PkeAllocator {
-public:
- typedef T value_type;
-
- PkeAllocator() = default;
-
- template <typename U> explicit PkeAllocator(const PkeAllocator<U> &other) {
- (void)other;
- }
-
- T *allocate(std::size_t n) {
- auto *ptr = Pke_New<T>(n);
- if (ptr) return ptr;
- throw "Pke-Allocator Failed to allocate";
- }
-
- void deallocate(const T *ptr, std::size_t n) {
- Pke_Delete<T>(ptr, n);
- }
-};
-
-#endif /* PKE_MEMORY_ALLOCATOR_HPP */