MemAllocator Interface

Table 1-2 summarizes the methods available through the MemAllocator interface.

Table 1-2 Summary of MemAllocator Methods; Ctx Package

Function Summary

alloc()

Allocates memory of given size.

dealloc()

Deallocate memory pointed to by the argument.

~MemAllocator()

Virtual destructor - interface level handle to actual destructors.



alloc()

This is a virtual member function that defines a prototype for user defined allocator functions

Syntax

virtual void* alloc(
   ub4 size) = 0;
Parameter Description
size
memory size


dealloc()

This is a virtual member function that defines a prototype for user defined deallocator functions. Such deallocators are supposed to deallocate memory allocated by the alloc member functions

Syntax

virtual void dealloc(
   void* ptr) = 0;
Parameter Description
ptr
pointer to previously allocated memory


~MemAllocator()

It provides an interface level handle to actual destructors that can be invoked without knowing their names or implementations

Syntax

virtual ~MemAllocator() {}