|
@@ -30,6 +30,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
namespace crown
|
|
namespace crown
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+/// Allocator based on C malloc().
|
|
|
class MallocAllocator : public Allocator
|
|
class MallocAllocator : public Allocator
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
@@ -37,15 +38,21 @@ public:
|
|
|
MallocAllocator();
|
|
MallocAllocator();
|
|
|
~MallocAllocator();
|
|
~MallocAllocator();
|
|
|
|
|
|
|
|
|
|
+ /// @copydoc Allocator::allocate()
|
|
|
void* allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
|
|
void* allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
|
|
|
|
|
+
|
|
|
|
|
+ /// @copydoc Allocator::deallocate()
|
|
|
void deallocate(void* data);
|
|
void deallocate(void* data);
|
|
|
|
|
|
|
|
|
|
+ /// @copydoc Allocator::allocated_size()
|
|
|
size_t allocated_size();
|
|
size_t allocated_size();
|
|
|
|
|
+
|
|
|
|
|
+ /// Returns the size in bytes of the block of memory pointed by @data
|
|
|
size_t get_size(void* data);
|
|
size_t get_size(void* data);
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
|
|
|
|
|
|
- //! Holds the number of bytes of an allocation
|
|
|
|
|
|
|
+ // Holds the number of bytes of an allocation
|
|
|
struct Header
|
|
struct Header
|
|
|
{
|
|
{
|
|
|
uint32_t size;
|
|
uint32_t size;
|