1#include "SmallVector.h"
3void Cogs::Collections::SmallVectorBase::growPod(
const void* firstElement,
const size_t minSizeBytes)
5 size_t newCapacity = capacityInBytes() * 2;
6 if (minSizeBytes > newCapacity) newCapacity = minSizeBytes;
8 const size_t currentSize = sizeInBytes();
11 if (firstPtr == firstElement) {
12 newPtr = allocator->
allocate(newCapacity);
14 std::memcpy(newPtr, firstPtr, currentSize);
16 newPtr = allocator->
allocate(newCapacity);
18 std::memcpy(newPtr, firstPtr, currentSize);
20 allocator->
deallocate(firstPtr, capacityInBytes());
24 lastPtr =
static_cast<uint8_t*
>(firstPtr) + currentSize;
25 capacityPtr =
static_cast<uint8_t*
>(firstPtr) + newCapacity;
virtual void deallocate(void *ptr, size_t size, MemBlockType type=MemBlockType::Block)
Deallocate the memory block at the given pointer, with the given size.
virtual void * allocate(size_t size, size_t alignment=0, MemBlockType type=MemBlockType::Block)
Allocate raw memory.