[#BloombergLP-bdlma-SequentialAllocator] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::SequentialAllocator :relfileprefix: ../../ :mrdocs: Fast allocator that dispenses heterogeneous blocks from dynamically allocated buffers. == Synopsis Declared in `<bdlma_sequentialallocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class SequentialAllocator : public xref:BloombergLP/bdlma/ManagedAllocator.adoc[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 [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlma/ManagedAllocator.adoc[ManagedAllocator]` | Protocol for allocators that support releasing all allocated memory. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/size_type.adoc[`size_type`] | Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/SequentialAllocator/2constructor-0df.adoc[`SequentialAllocator`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlma/SequentialAllocator/2destructor.adoc[`~SequentialAllocator`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this sequential allocator. All memory allocated from this allocator is released. | xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator=`] | | xref:BloombergLP/bdlma/SequentialAllocator/allocate-04.adoc[`allocate`] | `allocate` overloads | xref:BloombergLP/bdlma/SequentialAllocator/allocateAndExpand.adoc[`allocateAndExpand`] | Return a block of at least `*size` bytes and load the actual size into `*size`. | xref:BloombergLP/bdlma/SequentialAllocator/deallocate-034.adoc[`deallocate`] | This method has no effect; memory is managed by this allocator. | xref:BloombergLP/bslma/Allocator/deleteObject-09.adoc[`deleteObject`] | `deleteObject` overloads | xref:BloombergLP/bslma/Allocator/deleteObjectRaw-06f.adoc[`deleteObjectRaw`] | `deleteObjectRaw` overloads | xref:BloombergLP/bslma/Allocator/is_equal.adoc[`is_equal`] | | xref:BloombergLP/bdlma/SequentialAllocator/release.adoc[`release`] [.small]#[virtual]# | Release all memory allocated through this allocator. | xref:BloombergLP/bdlma/SequentialAllocator/reserveCapacity.adoc[`reserveCapacity`] | Reserve enough memory to satisfy at least `numBytes` of allocations without replenishment. | xref:BloombergLP/bdlma/SequentialAllocator/rewind.adoc[`rewind`] [.small]#[virtual]# | Release allocated memory while retaining this allocator's typical internal buffers. | xref:BloombergLP/bdlma/SequentialAllocator/truncate.adoc[`truncate`] | Reduce the most recently allocated block at `address` from `originalSize` to `newSize`. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] | Throw `std::bad_alloc` or abort the program. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do_allocate`] [.small]#[virtual]# | Return a newly allocated block of at least `bytes` with `alignment`. | xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do_deallocate`] [.small]#[virtual]# | Return the memory block at `p` having `bytes` and `alignment`. | xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do_is_equal`] [.small]#[virtual]# | Return whether this allocator can exchange memory with `other`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#