|
BDE 4.39.x Production Release
|
#include <bslma_default.h>
This struct is a mechanism with global state, i.e., all state is held in global variables and all functions are class methods. The state consists of two distinct parts that don't influence one another: the default allocator and the global allocator. All addresses are stored without assuming ownership.
The setDefaultAllocator method will only modify the default allocator prior to the default allocator being accessed (by either allocator, defaultAllocator, or lockDefaultAllocator). The global allocator may be freely modified.
main (or in testing), where the caller affirmatively takes responsibility for the behavior of all clients of the global allocator, is intended to change the global allocator.See bslma_default
Static Public Member Functions | |
| static int | setDefaultAllocator (Allocator *basicAllocator) |
| static void | setDefaultAllocatorRaw (Allocator *basicAllocator) |
| static void | lockDefaultAllocator () |
| static Allocator * | defaultAllocator () |
| static Allocator * | allocator (Allocator *basicAllocator=0) |
| static Allocator * | globalAllocator (Allocator *basicAllocator=0) |
| static Allocator * | setGlobalAllocator (Allocator *basicAllocator) |
Return the allocator returned by defaultAllocator and disable all subsequent calls to the setDefaultAllocator method if the optionally-specified basicAllocator is 0; return basicAllocator otherwise.
|
inlinestatic |
Return the address of the default allocator and disable all subsequent calls to the setDefaultAllocator method.
setDefaultAllocator or setDefaultAllocatorRaw methods, the address of the default allocator is that of the NewDeleteAllocator singleton. Also note that subsequent calls to setDefaultAllocatorRaw method are not disabled by this method. Return the address of the global allocator if the optionally- specified basicAllocator is 0, and basicAllocator otherwise.
setGlobalAllocator method, the address of the global allocator is that of the NewDeleteAllocator singleton.
|
inlinestatic |
Disable all subsequent calls to the setDefaultAllocator method. Subsequent calls to this method have no effect.
setDefaultAllocatorRaw method are not disabled by this method.
|
static |
Set the address of the default allocator to the specified basicAllocator unless calls to this method have been disabled. Return 0 on success and a non-zero value otherwise. This method will fail if either defaultAllocator, lockDefaultAllocator, or allocator with argument 0 has been called previously in this process. In C++17 and later, a successful call to this method will also set the default std::pmr::memory_resource.
basicAllocator is the address of an allocator with sufficient lifetime to satisfy all allocation requests within this process, and unless there is only one thread started within this process. main (or for use in testing) where the caller affirmatively takes responsibility for the behavior of all clients of the default allocator, and should not be used for any other purpose.
|
static |
Unconditionally set the address of the default allocator to the specified basicAllocator. In C++17 and later, a call to this method will also set the default std::pmr::memory_resource.
basicAllocator is the address of an allocator with sufficient lifetime to satisfy all allocation requests within this process, and unless there is only one thread started within this process. Unconditionally set the address of the global allocator to the specified basicAllocator, or to the address of the NewDeleteAllocator singleton if basicAllocator is 0. Return the address of the global allocator in effect immediately before calling this method.
basicAllocator is 0 or is the address of an allocator with sufficient lifetime to satisfy all global allocation requests within this process, and unless there is only one thread started within this process. NewDeleteAllocator singleton. Also note that this method is intended for use only by the owner of main (or for use in testing) where the caller affirmatively takes responsibility for the behavior of all clients of the global allocator, and should not be used for any other purpose.