AZStd uses simple and fast allocator model, it does not follow the CStd. It is not templated on any type, thus is doesn't care about construction or destruction. We do require name support, in most cases should be just a pointer to a literal.
This is the specification for an AZSTD allocator:
class allocator
{
public:
typedef <impl defined> pointer_type;
typedef <impl defined> size_type;
typedef <impl defined> difference_type;
typedef true_type (or false_type) allow_memory_leaks;
allocator(const char* name = "AZSTD Allocator");
allocator(const allocator& rhs);
allocator(const allocator& rhs, const char* name);
allocator& operator=(const allocator& rhs;
pointer_type allocate(size_type byteSize, size_type alignment, int flags = 0);
void deallocate(pointer_type ptr, size_type byteSize, size_type alignment);
size_type resize(pointer_type ptr, size_type newSize);
const char* get_name() const;
void set_name(const char* name);
size_type max_size() const;
<optional> size_type get_allocated_size() const;
};
bool operator==(const allocator& a, const allocator& b);
bool operator!=(const allocator& a, const allocator& b);
- Attention
- allow_memory_leaks is important to be set to true for temporary memory buffers like: stack allocators, etc. This will allow AZStd containers to have automatic "leak_and_reset" behavior, which will allow fast destroy without memory deallocation. This is especially important for temporary containers that make multiple allocations (like hash_maps, lists, etc.).