summaryrefslogtreecommitdiff
path: root/src/pso
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-02-07 17:21:05 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-02-07 17:21:05 -0400
commite679d990b85e0a92e2bb9de32dd229ceb50bb372 (patch)
tree493e6559ffa2fff53891f776d2df23bb96139f4a /src/pso
parentbcb51257d2a3fa6d0182cbb7c778c78ecf14bf54 (diff)
THeap: Use `sizeof(heap_node)` instead of `heap_offset`
Diffstat (limited to 'src/pso')
-rw-r--r--src/pso/THeap.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/pso/THeap.cpp b/src/pso/THeap.cpp
index 54772ff..8dd0894 100644
--- a/src/pso/THeap.cpp
+++ b/src/pso/THeap.cpp
@@ -6,8 +6,6 @@
#undef MATCHING
#define MATCHING
-static const int heap_offset = 8;
-
THeap *obj_heap;
THeap *alt_heap;
@@ -28,7 +26,7 @@ void *xmalloc(size_t size) {
}
void THeap::heap_free(void *ptr) {
- #define heap_ptr &ptr_u8[-heap_offset]
+ #define heap_ptr &ptr_u8[-sizeof(heap_node)]
#define ptr_heap ((heap_node *)heap_ptr)
const u8 *ptr_u8 = (u8 *)ptr;
if (ptr == NULL) {
@@ -70,7 +68,7 @@ void *THeap::heap_zalloc(size_t size) {
void *THeap::heap_alloc(size_t size) {
heap_node *prev_node = heap_nodes;
heap_node *node;
- u32 size_align = (heap_offset - 1) + align + size;
+ u32 size_align = (sizeof(heap_node) - 1) + align + size;
u32 aligned_size = size_align & -align;
goto start;
@@ -164,6 +162,6 @@ THeap::THeap(size_t size, int alignment) {
heap_nodes->remaining_size = 0;
next_tmp_node->next = NULL;
- next_tmp_node->remaining_size = size - heap_offset;
+ next_tmp_node->remaining_size = size - sizeof(heap_node);
}
}