Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Classes | Public Types | Public Member Functions | List of all members
jau::callocator< T > Struct Template Reference

A simple allocator using POSIX C functions: ::malloc(), ::free() and ::realloc(). More...

#include <callocator.hpp>

Inheritance diagram for jau::callocator< T >:
Collaboration diagram for jau::callocator< T >:

Classes

struct  rebind
 

Public Types

typedef T value_type
 

Public Member Functions

 callocator () noexcept
 
 callocator (const callocator &other) noexcept
 
template<typename U >
 callocator (const callocator< U > &other) noexcept
 
 ~callocator ()
 
value_typeallocate (std::size_t n, const void *hint)
 
value_typeallocate (std::size_t n)
 
constexpr value_typereallocate (value_type *p, std::size_t old_size, std::size_t new_size)
 
void deallocate (value_type *p, std::size_t n)
 

Detailed Description

template<class T>
struct jau::callocator< T >

A simple allocator using POSIX C functions: ::malloc(), ::free() and ::realloc().


It is the missing ::realloc() in std::allocator, motivating this class.
Since realloc() requires the passed pointer to originate from malloc() or calloc, we have to use it for allocate() as well.

Added method is reallocate() using the native realloc().

This class shall be compliant with C++ named requirements for Allocator.

Not implementing deprecated (C++17) and removed (C++20) methods: address(), max_size(), construct() and destroy().

Examples
test_cow_darray_01.cpp, and test_cow_darray_perf01.cpp.

Definition at line 52 of file callocator.hpp.

Member Typedef Documentation

◆ value_type

template<class T >
typedef T jau::callocator< T >::value_type

Definition at line 58 of file callocator.hpp.

Constructor & Destructor Documentation

◆ callocator() [1/3]

template<class T >
jau::callocator< T >::callocator ( )
inlinenoexcept

Definition at line 61 of file callocator.hpp.

◆ callocator() [2/3]

template<class T >
jau::callocator< T >::callocator ( const callocator< T > &  other)
inlinenoexcept

Definition at line 68 of file callocator.hpp.

◆ callocator() [3/3]

template<class T >
template<typename U >
jau::callocator< T >::callocator ( const callocator< U > &  other)
inlinenoexcept

Definition at line 78 of file callocator.hpp.

◆ ~callocator()

template<class T >
jau::callocator< T >::~callocator ( )
inline

Definition at line 85 of file callocator.hpp.

Member Function Documentation

◆ allocate() [1/2]

template<class T >
value_type* jau::callocator< T >::allocate ( std::size_t  n)
inline

Definition at line 100 of file callocator.hpp.

◆ allocate() [2/2]

template<class T >
value_type* jau::callocator< T >::allocate ( std::size_t  n,
const void *  hint 
)
inline

Definition at line 89 of file callocator.hpp.

Here is the caller graph for this function:

◆ deallocate()

template<class T >
void jau::callocator< T >::deallocate ( value_type p,
std::size_t  n 
)
inline

Definition at line 117 of file callocator.hpp.

Here is the caller graph for this function:

◆ reallocate()

template<class T >
constexpr value_type* jau::callocator< T >::reallocate ( value_type p,
std::size_t  old_size,
std::size_t  new_size 
)
inlineconstexpr

Definition at line 105 of file callocator.hpp.

Here is the caller graph for this function:

The documentation for this struct was generated from the following file: