summaryrefslogtreecommitdiff
path: root/src/util/allocator.h
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2025-11-28 14:41:22 +0100
committerGitHub <noreply@github.com>2025-11-28 14:41:22 +0100
commit9c05c795d7b59c5ab94fb769f315c712b37df0cd (patch)
tree16cccf8cbb88703de798066a06f94013f89a8a5a /src/util/allocator.h
parentf8b92ce3aa08b1445c9f956d8166830946562d12 (diff)
parent3e094f20d4dda90e0356aba3f0abc4b7c7015844 (diff)
Merge pull request #1 from navewindre/windows-compat
Windows compat
Diffstat (limited to 'src/util/allocator.h')
-rw-r--r--src/util/allocator.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/allocator.h b/src/util/allocator.h
index ee0ddd8..27b21c0 100644
--- a/src/util/allocator.h
+++ b/src/util/allocator.h
@@ -161,6 +161,22 @@ struct LIST {
return &data[size - 1];
}
+ void resize( U32 size ) {
+ if( size > capacity )
+ reserve( size * 2 );
+
+ if( size < capacity / 4 )
+ shrink();
+
+ if( this->size < size ) {
+ memset( &data[this->size], 0, sizeof(T) * (size - this->size) );
+ for( U32 i = this->size; i < size; ++i )
+ data[i] = T();
+ }
+
+ this->size = size;
+ }
+
// does not call copy constructors, raw memcpy
void emplace_list( const LIST<T>& list ) {
if( !list.size )
@@ -250,6 +266,16 @@ struct LIST {
return -1;
}
+ I32 idx_of( const T* what ) {
+ for( U32 i = 0; i < size; ++i ) {
+ if( &data[i] == what ) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
I32 idx_where( ON_SEARCH_FN what ) {
for( U32 i = 0; i < size; ++i ) {
if( what( &data[i] ) ) {