Fast allocator that dispenses heterogeneous blocks from dynamically allocated buffers.

Synopsis

Declared in <bdlma_sequentialallocator.h>

class SequentialAllocator
    : public ManagedAllocator

Description

This class implements the ManagedAllocator protocol to provide a fast allocator that dispenses heterogeneous blocks of memory (of varying, user‐specified sizes) from a sequence of dynamically‐allocated buffers. Memory for the internal buffers is supplied by an (optional) allocator supplied at construction; if no allocator is supplied, the currently installed default allocator is used. If an allocation exceeds the remaining free memory space in the current buffer, the allocator replenishes its internal buffer with new memory to satisfy the request. This class is exception neutral: If memory cannot be allocated, the behavior is defined by the (optional) allocator specified at construction.

Base Classes

Name

Description

ManagedAllocator

Protocol for allocators that support releasing all allocated memory.

Type Aliases

Name

Description

size_type

Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space.

Member Functions

Name

Description

SequentialAllocator [constructor]

Constructors

~SequentialAllocator [destructor] [virtual]

Destroy this sequential allocator. All memory allocated from this allocator is released.

operator=

allocate

allocate overloads

allocateAndExpand

Return a block of at least *size bytes and load the actual size into *size.

deallocate

This method has no effect; memory is managed by this allocator.

deleteObject

deleteObject overloads

deleteObjectRaw

deleteObjectRaw overloads

is_equal

release [virtual]

Release all memory allocated through this allocator.

reserveCapacity

Reserve enough memory to satisfy at least numBytes of allocations without replenishment.

rewind [virtual]

Release allocated memory while retaining this allocator's typical internal buffers.

truncate

Reduce the most recently allocated block at address from originalSize to newSize.

Static Member Functions

Name

Description

throwBadAlloc

Throw std::bad_alloc or abort the program.

Protected Member Functions

Name

Description

do_allocate [virtual]

Return a newly allocated block of at least bytes with alignment.

do_deallocate [virtual]

Return the memory block at p having bytes and alignment.

do_is_equal [virtual]

Return whether this allocator can exchange memory with other.

Created with MrDocs