summaryrefslogtreecommitdiff
path: root/src/dynamic-array.hpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-11-14 14:46:23 -0500
committerJonathan Bradley <jcb@pikum.xyz>2024-11-14 14:46:23 -0500
commitb2548ba4ce295fcd94a50123fb543fac2ef2bc33 (patch)
tree444a32abb4a094c4fa2f7bc9a95aa86963ad4110 /src/dynamic-array.hpp
parentb1d926361b9d613ad712ad161f9a8b7ccab4551d (diff)
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
Diffstat (limited to 'src/dynamic-array.hpp')
-rw-r--r--src/dynamic-array.hpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp
index 4003b63..a676b40 100644
--- a/src/dynamic-array.hpp
+++ b/src/dynamic-array.hpp
@@ -1,18 +1,18 @@
#ifndef PKE_DYNAMIC_ARRAY_HPP
#define PKE_DYNAMIC_ARRAY_HPP
-#include "memory.hpp"
-#include "macros.hpp"
+#include "vendor/pk.h"
#include <cstdint>
#include <cstring>
#include <cassert>
#include <type_traits>
+#include <new>
#define BAKE_DYN_ARRAY(T) template struct DynArray<T>;
struct DynArrayBase {
- mutable MemBucket *bkt = nullptr;
+ mutable struct pk_membucket *bkt = nullptr;
mutable char *ptr = nullptr;
int64_t elementSize = 0;
int64_t elementCount = 0;
@@ -21,8 +21,8 @@ struct DynArrayBase {
template <typename T>
struct DynArray: DynArrayBase {
- explicit DynArray(MemBucket *bucket = nullptr);
- explicit DynArray(int64_t reserveCount, MemBucket *bucket = nullptr);
+ explicit DynArray(struct pk_membucket *bucket = nullptr);
+ explicit DynArray(int64_t reserveCount, struct pk_membucket *bucket = nullptr);
DynArray(const DynArray<T> &other);
DynArray(DynArray<T> &&other);
DynArray &operator=(const DynArray<T> &other);
@@ -51,7 +51,7 @@ struct DynArray: DynArrayBase {
void DynArrayReserve(DynArrayBase *arr, int64_t count);
void DynArrayDestroy(DynArrayBase *arr);
-template <typename T> inline DynArray<T>::DynArray(int64_t count, MemBucket *bucket) {
+template <typename T> inline DynArray<T>::DynArray(int64_t count, struct pk_membucket *bucket) {
this->bkt = bucket;
this->elementSize = sizeof(T);
if (count > 0) DynArrayReserve(this, count);
@@ -62,7 +62,7 @@ template <typename T> inline DynArray<T>::DynArray(int64_t count, MemBucket *buc
}
}
-template <typename T> inline DynArray<T>::DynArray(MemBucket *bucket) {
+template <typename T> inline DynArray<T>::DynArray(struct pk_membucket *bucket) {
this->bkt = bucket;
this->elementSize = sizeof(T);
}
@@ -194,10 +194,10 @@ template <typename T> inline void DynArray<T>::Remove(std::size_t index, int64_t
this->elementCount = index;
return;
}
- T *tmp = Pke_New<T>(moveCount, this->bkt);
+ T *tmp = pk_new<T>(moveCount, this->bkt);
memcpy(tmp, this->ptr + (sizeof(T) * (index + count)), sizeof(T) * moveCount);
memcpy(this->ptr + (sizeof(T) * index), tmp, sizeof(T) * moveCount);
- Pke_Delete<T>(tmp, moveCount, this->bkt);
+ pk_delete<T>(tmp, moveCount, this->bkt);
this->elementCount -= count;
}