Class Allocator
Manager for allocated memory.

All Subcl's MultiPoolAllocator, SimpleAllocator, SinglePoolAllocator
Defined in <seqan/basic.h>
Signature template <typename TSpec> class Allocator;

Template Parameters

TSpec The specializing type.

Interface Function Overview

Detailed Description

Remarks

There are two reasons for using non-trivial allocators:

  1. Allocators support the function clear for a fast deallocation of all allocated memory blocks.
  2. Some allocators are faster in allocating an deallocating memory. Pool allocators like e.g. SinglePoolAllocator or MultiPoolAllocator speed up allocate, *, and clear for pooled memory blocks.

Interface Functions Detail

void allocate(allocator, data, count[, usageTag]);

Allocates memory from heap.

Parameters

count Number of items that could be stored in the allocated memory. The type of the allocated items is given by the type of data.
usageTag A tag the specifies the purpose for the allocated memory. Values: AllocatorUsageTags.
allocator Allocator object. allocator is conceptually the "owner" of the allocated memory. Objects of all types can be used as allocators. If no special behavior is implemented, default functions allocation/deallocation are applied that uses standard new and delete operators. Types: Allocator

Remarks

The function allocates at least count*sizeof(data) bytes. The allocated memory is large enough to hold count objects of type T, where T * is type of data.

These objects are not constructed by allocate.

Use e.g. one of the functions valueConstruct, arrayConstruct, arrayConstructCopy or arrayFill to construct the objects. A new operator which is part of the C++ standard (defined in <new>) can also be used to construct objects at a given memory address.

Remarks

All allocated memory blocks should be deallocated by the corresponding function deallocate.

Data Races

Thread safety unknown!

void clear(allocator);

Deallocates all memory blocks.

Parameters

The allocator to clear.

Remarks

This function deallocates all memory block sthat were allocated using allocate() for allocator. The memory is not pooled but directly passed back to the heap manager.

Data Races

Thread safety unknown!

void deallocate(object, data, count[, usageTag])

Deallocates memory.

Parameters

object Allocator object.object is conceptually the "owner" of the allocated memory. Objects of all types can be used as allocators. If no special behavior is implemented, default functions allocation/deallocation are applied that uses standard new and delete operators. Types: Allocator
data Pointer to allocated memory that was allocated by allocate.
count Number of items that could be stored in the allocated memory.
usageTag A tag the specifies the purpose for the allocated memory. Values: AllocatorUsageTags.

The values for object, count and usageTag should be the same that was used when allocate was called. The value of data should be the same that was returned by allocate.

deallocate does not destruct objects.

Use e.g. one of the functions valueDestruct or arrayDestruct to destruct the objects. delete and delete [] operators which are part of the C++ standard (defined in <new>) can also be used to destruct objects at a given memory address.

Data Races

Thread safety unknown!