Create an auto deallocator to manage a sequence of memory blocks.
Declared in <bslma_autodeallocator.h>
AutoDeallocator(
void** origin,
ALLOCATOR* allocator,
int length = 0);
Create an auto deallocator to manage a sequence of memory blocks at the specified origin, and that uses the specified allocator to deallocate the sequence of memory blocks managed by this range proctor (if not released -- see release) upon destruction. Optionally specify length to define its range, which by default is empty (i.e., length = 0). The sequence of memory blocks may extend in either direction from origin. A positive length represents the sequence of memory blocks starting at origin and extending "up" to length (not including the memory block at the index position origin + length). A negative length represents the sequence of memory blocks starting at one position below origin and extending "down" to the absolute value of length (including the memory block at index position origin + length). If length is 0, then this range proctor manages no memory blocks. If origin is non-zero, all memory blocks within the proctored range (if any) must be supplied by allocator. The behavior is undefined unless allocator is non-zero, and, if origin is 0, length is also 0. Note that when length is non-positive, the memory block at the origin is not managed by this range proctor.
| Name | Description |
|---|---|
| origin | The address of the origin memory block pointer. |
| allocator | The allocator used to deallocate managed memory blocks. |
| length | The signed length of the managed memory block sequence. |