This class provides direct access to the system‐supplied (native) global std::malloc and std::free.

Synopsis

Declared in <bslma_mallocfreeallocator.h>

class MallocFreeAllocator
    : public Allocator

Description

A static method is provided for obtaining a unique, process wide object of this class, which is valid from the time the method is called until after the program (not just main) exits.

Base Classes

Name

Description

Allocator

Pure abstract protocol for clients and suppliers of raw 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

MallocFreeAllocator [constructor]

Create an allocator that uses std::malloc and std::free to supply memory. Note that all objects of this class share the same underlying resource.

~MallocFreeAllocator [destructor] [virtual]

Destroy this allocator.

operator=

allocate

Return a newly allocated block of memory of the specified size bytes.

deallocate

Return the memory block at the specified address to this allocator.

deleteObject

deleteObject overloads

deleteObjectRaw

deleteObjectRaw overloads

is_equal

Static Member Functions

Name

Description

singleton

Return a reference to a valid object of this class.

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