summaryrefslogtreecommitdiff
path: root/src/util/allocator.h
diff options
context:
space:
mode:
authorday <day@national.shitposting.agency>2026-03-16 16:25:49 +0100
committerday <day@national.shitposting.agency>2026-03-16 16:25:49 +0100
commit7f85c9fc75bd62ac09ea4457d3b17f85988fca66 (patch)
tree15248e42bfafc6bd19e50c9010b701057958ff3a /src/util/allocator.h
parent872c39b24ecf4063f785ff3e8b2f940acd8c2d59 (diff)
parent991352b0d2767e6bd1a46f554db4ac9d208c13ad (diff)
Merge remote-tracking branch 'origin/master' into obj
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();