diff options
| author | navewindre <boneyaard@gmail.com> | 2025-11-27 17:19:02 +0100 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-11-27 17:21:48 +0100 |
| commit | e3de3ba5162f7ddd5005911124d4333e140fd984 (patch) | |
| tree | efb2d3851940ba1b70f0105611cddb17344e7e32 /src/util/allocator.h | |
| parent | 5c8bbc3bc618068af1f7d6f2829c4346570c2ab9 (diff) | |
bunch o stuff
Diffstat (limited to 'src/util/allocator.h')
| -rw-r--r-- | src/util/allocator.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/util/allocator.h b/src/util/allocator.h index 7927b9c..27b21c0 100644 --- a/src/util/allocator.h +++ b/src/util/allocator.h @@ -165,8 +165,12 @@ struct LIST { if( size > capacity ) reserve( size * 2 ); - if( size < capacity ) { - for( U32 i = size; i < capacity; ++i ) + 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(); } @@ -262,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] ) ) { |
