summaryrefslogtreecommitdiff
path: root/src/util/allocator.h
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-16 10:15:01 +0100
committeraura <nw@moneybot.cc>2026-03-16 10:15:01 +0100
commitfdc5e8760fb7ac0af8e7ebb98a2076db15e31082 (patch)
treec94991e1e594c7703295aa413caf40786f343c1f /src/util/allocator.h
parente2829336cfedb39d23263f75b61ed969c8193534 (diff)
giga refactor, fix ALL the leaks
Diffstat (limited to 'src/util/allocator.h')
-rw-r--r--src/util/allocator.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/util/allocator.h b/src/util/allocator.h
index 327dfc1..623d227 100644
--- a/src/util/allocator.h
+++ b/src/util/allocator.h
@@ -2,8 +2,7 @@
#include <stdlib.h>
#include <string.h>
-#include <functional>
-#include "typedef.h"
+#include "callback.h"
template <typename T>
struct LIST_ITERATOR {
@@ -19,7 +18,7 @@ struct LIST_ITERATOR {
};
template <typename T>
-using QSORT_FN = std::function< U8( T*, T* ) >;
+using QSORT_FN = FN< U8( T*, T* ) >;
template <typename T>
static U8 qsort_basic_sort( T* t1, T* t2 ) {
@@ -58,8 +57,8 @@ struct LIST {
U32 capacity;
U32 size;
- using ON_EACH_FN = std::function< void(T*) >;
- using ON_SEARCH_FN = std::function< bool(T*) >;
+ using ON_EACH_FN = FN< void(T*) >;
+ using ON_SEARCH_FN = FN< U8(T*) >;
LIST() {
data = (T*)malloc( sizeof( T ) );
@@ -265,6 +264,8 @@ struct LIST {
}
T ret = data[--size];
+ if constexpr( !__is_trivially_destructible(T) )
+ data[size].~T();
if( size < capacity / 4 )
shrink();