From b2548ba4ce295fcd94a50123fb543fac2ef2bc33 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 14 Nov 2024 14:46:23 -0500 Subject: add pk.h and major pkmem refactor Completely replaces the memory module with pkmem pkmem is a newer implementation of the same bucket memory structure. Also includes replacing pkstr.h with pk.h's pkstr --- src/memory-allocator.hpp | 54 ------------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 src/memory-allocator.hpp (limited to 'src/memory-allocator.hpp') 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 class PkeTransAllocator { -public: - typedef T value_type; - MemBucket *transientBucket = nullptr; - - PkeTransAllocator() : transientBucket(Pke_BeginTransientBucket(SZ)) { - } - ~PkeTransAllocator() { - Pke_EndTransientBucket(this->transientBucket); - } - - template struct rebind {typedef PkeTransAllocator other;}; - template explicit PkeTransAllocator(const PkeTransAllocator &other) { - (void)other; - } - - T *allocate(std::size_t n) { - auto *ptr = reinterpret_cast(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 class PkeAllocator { -public: - typedef T value_type; - - PkeAllocator() = default; - - template explicit PkeAllocator(const PkeAllocator &other) { - (void)other; - } - - T *allocate(std::size_t n) { - auto *ptr = Pke_New(n); - if (ptr) return ptr; - throw "Pke-Allocator Failed to allocate"; - } - - void deallocate(const T *ptr, std::size_t n) { - Pke_Delete(ptr, n); - } -}; - -#endif /* PKE_MEMORY_ALLOCATOR_HPP */ -- cgit v1.2.3