jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
jau::callocator_sec< T, > Struct Template Reference

A simple secure allocator for integral types using POSIX C functions: ::malloc() and ::free(). More...

#include <callocator_sec.hpp>

Inheritance diagram for jau::callocator_sec< T, >:
Collaboration diagram for jau::callocator_sec< T, >:

Classes

struct  rebind
 

Public Types

typedef const T * const_pointer
 
typedef const T & const_reference
 
typedef std::ptrdiff_t difference_type
 
typedef std::true_type is_always_equal
 
typedef T * pointer
 
typedef std::true_type propagate_on_container_move_assignment
 
typedef T & reference
 
typedef std::size_t size_type
 
typedef T value_type
 

Public Member Functions

 callocator_sec () noexcept=default
 
 callocator_sec (const callocator_sec &) noexcept
 
template<typename U>
 callocator_sec (const callocator_sec< U > &) noexcept
 
 ~callocator_sec ()=default
 
value_typeallocate (std::size_t n)
 
value_typeallocate (std::size_t n, const void *)
 
void deallocate (value_type *p, std::size_t n) noexcept
 

Detailed Description

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
struct jau::callocator_sec< T, >

A simple secure allocator for integral types using POSIX C functions: ::malloc() and ::free().

callocator_sec is similar to callocator, but

  • only works for integral types
  • deallocate explicitly zero_bytes_sec() the memory before free for secure scrubbing.
  • dropped realloc() for security reasons, since realloc() could free old memory block w/o scrubbing.

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().

Definition at line 52 of file callocator_sec.hpp.

Member Typedef Documentation

◆ value_type

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef T jau::callocator_sec< T, >::value_type

Definition at line 56 of file callocator_sec.hpp.

◆ size_type

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef std::size_t jau::callocator_sec< T, >::size_type

Definition at line 57 of file callocator_sec.hpp.

◆ difference_type

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef std::ptrdiff_t jau::callocator_sec< T, >::difference_type

Definition at line 58 of file callocator_sec.hpp.

◆ propagate_on_container_move_assignment

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef std::true_type jau::callocator_sec< T, >::propagate_on_container_move_assignment

Definition at line 59 of file callocator_sec.hpp.

◆ is_always_equal

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef std::true_type jau::callocator_sec< T, >::is_always_equal

Definition at line 62 of file callocator_sec.hpp.

◆ pointer

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef T* jau::callocator_sec< T, >::pointer

Definition at line 65 of file callocator_sec.hpp.

◆ const_pointer

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef const T* jau::callocator_sec< T, >::const_pointer

Definition at line 66 of file callocator_sec.hpp.

◆ reference

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef T& jau::callocator_sec< T, >::reference

Definition at line 67 of file callocator_sec.hpp.

◆ const_reference

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
typedef const T& jau::callocator_sec< T, >::const_reference

Definition at line 68 of file callocator_sec.hpp.

Constructor & Destructor Documentation

◆ callocator_sec() [1/3]

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
jau::callocator_sec< T, >::callocator_sec ( )
defaultnoexcept

◆ callocator_sec() [2/3]

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
jau::callocator_sec< T, >::callocator_sec ( const callocator_sec< T, > & )
inlinenoexcept

Definition at line 83 of file callocator_sec.hpp.

◆ callocator_sec() [3/3]

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
template<typename U>
jau::callocator_sec< T, >::callocator_sec ( const callocator_sec< U > & )
inlinenoexcept

Definition at line 93 of file callocator_sec.hpp.

◆ ~callocator_sec()

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
jau::callocator_sec< T, >::~callocator_sec ( )
default

Member Function Documentation

◆ allocate() [1/2]

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
value_type * jau::callocator_sec< T, >::allocate ( std::size_t n,
const void *  )
inline

Definition at line 104 of file callocator_sec.hpp.

◆ allocate() [2/2]

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
value_type * jau::callocator_sec< T, >::allocate ( std::size_t n)
inline

Definition at line 114 of file callocator_sec.hpp.

◆ deallocate()

template<typename T, std::enable_if_t< std::is_integral_v< T >, bool > = true>
void jau::callocator_sec< T, >::deallocate ( value_type * p,
std::size_t n )
inlinenoexcept

Definition at line 125 of file callocator_sec.hpp.


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