STK++ 0.9.13
STK::hidden::MemHandler< Type_, Size_ > Struct Template Reference

Helper class allowing to free memory (or not) More...

#include <STK_MemAllocator.h>

Public Types

typedef TRange< Size_AllocatorRange
 

Static Public Member Functions

static Type_ * free (Type_ *p_data, AllocatorRange const &range)
 do nothing for fixed size allocators !
 
static Type_ * malloc (Type_ *p_data, AllocatorRange const &range)
 malloc memory.
 
template<int OtherSize>
static Type_ * realloc (Type_ *p_data, AllocatorRange const &range, TRange< OtherSize > const &I)
 realloc main pointer and copy existing data.
 

Detailed Description

template<typename Type_, int Size_>
struct STK::hidden::MemHandler< Type_, Size_ >

Helper class allowing to free memory (or not)

Note
for fixed size containers, free do nothing, realloc adjust the shift

Definition at line 58 of file STK_MemAllocator.h.

Member Typedef Documentation

◆ AllocatorRange

template<typename Type_ , int Size_>
typedef TRange<Size_> STK::hidden::MemHandler< Type_, Size_ >::AllocatorRange

Definition at line 60 of file STK_MemAllocator.h.

Member Function Documentation

◆ free()

template<typename Type_ , int Size_>
static Type_ * STK::hidden::MemHandler< Type_, Size_ >::free ( Type_ *  p_data,
AllocatorRange const range 
)
inlinestatic

do nothing for fixed size allocators !

Definition at line 62 of file STK_MemAllocator.h.

62{ return p_data;}

Referenced by STK::MemAllocator< Type_, Size_ >::forcedFree(), and STK::hidden::MemHandler< Type_, UnknownSize >::realloc().

◆ malloc()

template<typename Type_ , int Size_>
static Type_ * STK::hidden::MemHandler< Type_, Size_ >::malloc ( Type_ *  p_data,
AllocatorRange const range 
)
inlinestatic

malloc memory.

allocate memory is not allocated yet, otherwise do nothing.

Definition at line 66 of file STK_MemAllocator.h.

67 {
68 if (!p_data)
69 {
70 if(range.size()>0)
71 {
72 p_data = new Type_[range.size()];
73 p_data -= range.begin();
74 }
75 }
76 return p_data;
77 }

Referenced by STK::hidden::MemHandler< Type_, UnknownSize >::realloc().

◆ realloc()

template<typename Type_ , int Size_>
template<int OtherSize>
static Type_ * STK::hidden::MemHandler< Type_, Size_ >::realloc ( Type_ *  p_data,
AllocatorRange const range,
TRange< OtherSize > const I 
)
inlinestatic

realloc main pointer and copy existing data.

Definition at line 80 of file STK_MemAllocator.h.

81 {
82 // fixed size, just shift
83 return p_data + range.begin() - I.begin();
84 }

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