diff options
Diffstat (limited to 'src/util/allocator.h')
| -rw-r--r-- | src/util/allocator.h | 11 |
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(); |
