|
| allocator () |
| Constructor.
|
|
virtual | ~allocator () |
| Destructor.
|
|
virtual bool | operator== (const allocator &with)=0 |
| Compare for equality two objects of this class type. More...
|
|
virtual bool | operator!= (const allocator &with)=0 |
| Compare for inequlity two objects of this class type. More...
|
|
virtual void * | malloc (size_t bytes, size_t alignment=alignment_boundary)=0 |
| Allocate a small chunk of memory from the internal pool and return a pointer to the caller. More...
|
|
size_t | capacity (void) const |
| Return the amount of memory that this object has allocated to it. More...
|
|
size_t | size (void) const |
| Return the number of bytes of memory this object has handed back to callers. More...
|
|
virtual void | rewind (void)=0 |
| Throw away (without calling delete) all objects allocated in the memory space of this allocator Delete is not called for any objects allocated in this space, the memory is simply re-claimed.
|
|
Virtual base class for C style allocators.
All allocators are thread safe. A single allocator can be called from multiple threads concurrently and they will each return a valid pointer to a piece of memory that is not overlapping with any pointer returned from any other call and is of the requested size.
static size_t JASS::allocator::realign |
( |
const void * |
address, |
|
|
size_t |
boundary |
|
) |
| |
|
inlinestatic |
Compute the number of extra bytes of memory necessary for an allocation to start on an aligned boundary.
Aligning all allocations on a machine-word boundary is a space / space trade off. Allocating a string of single bytes one after the other and word-aligned would result in a machine word being used per byte. To avoid this wastage this class, by default, does not word-align any allocations. However, it is sometimes necessary to word-align because some assembly instructions require word-alignment. This method return the number of bytes of padding necessary to make an address word-aligned.
- Parameters
-
address | [in] Compute the number of wasted bytes from this address to the next bounday |
boundary | [in] The byte-boundary to which this address should be alligned (e.g. 4 will ensure the least significant 2 bits are alwasys 00) |
- Returns
- The number of bytes to add to address to make it aligned