summaryrefslogtreecommitdiff
path: root/src/memory.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.cc')
-rw-r--r--src/memory.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/memory.cc b/src/memory.cc
index 2d83413..1cb6cb9 100644
--- a/src/memory.cc
+++ b/src/memory.cc
@@ -16,11 +16,11 @@ struct Allocator {
Allocator_Deallocate deallocate;
};
-u8* allocate(Allocator* allocator, usize size, usize align) {
+u8* allocate(const Allocator* allocator, usize size, usize align) {
return allocator->allocate(allocator->self, size, align);
}
-void deallocate(Allocator* allocator, u8* ptr) {
+void deallocate(const Allocator* allocator, u8* ptr) {
allocator->deallocate(allocator->self, ptr);
}
@@ -34,14 +34,14 @@ static inline void heap_deallocate(u8* self, u8* ptr) {
mi_free(ptr);
}
-Allocator* heap_allocator() {
+const Allocator* heap_allocator() {
thread_local Allocator HEAP_ALLOCATOR = {nullptr, heap_allocate,
heap_deallocate};
return &HEAP_ALLOCATOR;
}
template <typename T>
-bool slice_copy(Allocator* allocator, const Slice<T>* source, Slice<T>* out) {
+bool slice_copy(const Allocator* allocator, const Slice<T>* source, Slice<T>* out) {
T* new_ptr = allocate(allocator, source->size(), alignof(T));
if (new_ptr == nullptr) return false;
@@ -53,7 +53,7 @@ bool slice_copy(Allocator* allocator, const Slice<T>* source, Slice<T>* out) {
}
template <typename T>
-void slice_deallocate(Allocator* allocator, Slice<T>* slice) {
+void slice_deallocate(const Allocator* allocator, Slice<T>* slice) {
if (slice->ptr == nullptr) return;
deallocate(allocator, (u8*)slice->ptr);