From fdc5e8760fb7ac0af8e7ebb98a2076db15e31082 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 10:15:01 +0100 Subject: giga refactor, fix ALL the leaks --- src/util/allocator.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/util/allocator.h') 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 #include -#include -#include "typedef.h" +#include "callback.h" template struct LIST_ITERATOR { @@ -19,7 +18,7 @@ struct LIST_ITERATOR { }; template -using QSORT_FN = std::function< U8( T*, T* ) >; +using QSORT_FN = FN< U8( T*, T* ) >; template 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(); -- cgit v1.2.3