foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pfc::alloc_simple< t_item >

#include <alloc.h>

Public Types

enum  { alloc_prioritizes_speed = false }
 

Public Member Functions

 alloc_simple ()
 
 ~alloc_simple ()
 
void force_reset ()
 
t_item * get_ptr ()
 
const t_item * get_ptr () const
 
t_size get_size () const
 
bool is_ptr_owned (const void *p_item) const
 
void move_from (t_self &other)
 
const t_item & operator[] (t_size p_index) const
 
t_item & operator[] (t_size p_index)
 
void prealloc (t_size)
 
void set_size (t_size p_size)
 

Private Types

typedef alloc_simple< t_item > t_self
 

Private Member Functions

 alloc_simple (const t_self &)
 
const t_selfoperator= (const t_self &)
 

Private Attributes

t_item * m_data
 
t_size m_size
 

Detailed Description

template<typename t_item>
class pfc::alloc_simple< t_item >

Simple inefficient fully portable allocator.

Definition at line 90 of file alloc.h.

Member Typedef Documentation

template<typename t_item >
typedef alloc_simple<t_item> pfc::alloc_simple< t_item >::t_self
private

Definition at line 91 of file alloc.h.

Member Enumeration Documentation

template<typename t_item >
anonymous enum
Enumerator
alloc_prioritizes_speed 

Definition at line 114 of file alloc.h.

Constructor & Destructor Documentation

template<typename t_item >
pfc::alloc_simple< t_item >::alloc_simple ( )
inline

Definition at line 93 of file alloc.h.

93 : m_data(NULL), m_size(0) {}
t_size m_size
Definition: alloc.h:134
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
pfc::alloc_simple< t_item >::~alloc_simple ( )
inline

Definition at line 122 of file alloc.h.

122 {delete[] m_data;}
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
pfc::alloc_simple< t_item >::alloc_simple ( const t_self )
inlineprivate

Definition at line 131 of file alloc.h.

131 {throw pfc::exception_not_implemented();}

Member Function Documentation

template<typename t_item >
void pfc::alloc_simple< t_item >::force_reset ( )
inline

Definition at line 120 of file alloc.h.

120 {set_size(0);}
void set_size(t_size p_size)
Definition: alloc.h:94
template<typename t_item >
t_item* pfc::alloc_simple< t_item >::get_ptr ( )
inline

Definition at line 116 of file alloc.h.

116 {return m_data;}
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
const t_item* pfc::alloc_simple< t_item >::get_ptr ( ) const
inline

Definition at line 117 of file alloc.h.

117 {return m_data;}
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
t_size pfc::alloc_simple< t_item >::get_size ( ) const
inline

Definition at line 109 of file alloc.h.

109 {return m_size;}
t_size m_size
Definition: alloc.h:134
template<typename t_item >
bool pfc::alloc_simple< t_item >::is_ptr_owned ( const void *  p_item) const
inline

Definition at line 112 of file alloc.h.

112 {return is_pointer_in_range(get_ptr(),get_size(),p_item);}
t_item * get_ptr()
Definition: alloc.h:116
t_size get_size() const
Definition: alloc.h:109
bool is_pointer_in_range(const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
Definition: alloc.h:84
template<typename t_item >
void pfc::alloc_simple< t_item >::move_from ( t_self other)
inline

Definition at line 124 of file alloc.h.

124  {
125  delete[] m_data;
126  m_data = replace_null_t(other.m_data);
127  m_size = replace_null_t(other.m_size);
128  }
t_type replace_null_t(t_type &p_var)
Definition: primitives.h:688
t_size m_size
Definition: alloc.h:134
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
const t_self& pfc::alloc_simple< t_item >::operator= ( const t_self )
inlineprivate

Definition at line 130 of file alloc.h.

130 {throw pfc::exception_not_implemented();}
template<typename t_item >
const t_item& pfc::alloc_simple< t_item >::operator[] ( t_size  p_index) const
inline

Definition at line 110 of file alloc.h.

110 {PFC_ASSERT(p_index < m_size); return m_data[p_index];}
t_size m_size
Definition: alloc.h:134
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
t_item& pfc::alloc_simple< t_item >::operator[] ( t_size  p_index)
inline

Definition at line 111 of file alloc.h.

111 {PFC_ASSERT(p_index < m_size); return m_data[p_index];}
t_size m_size
Definition: alloc.h:134
t_item * m_data
Definition: alloc.h:133
template<typename t_item >
void pfc::alloc_simple< t_item >::prealloc ( t_size  )
inline

Definition at line 119 of file alloc.h.

119 {}
template<typename t_item >
void pfc::alloc_simple< t_item >::set_size ( t_size  p_size)
inline

Definition at line 94 of file alloc.h.

94  {
95  if (p_size != m_size) {
96  t_item * l_data = NULL;
97  if (p_size > 0) l_data = new t_item[p_size];
98  try {
99  pfc::memcpy_t(l_data,m_data,pfc::min_t(m_size,p_size));
100  } catch(...) {
101  delete[] l_data;
102  throw;
103  }
104  delete[] m_data;
105  m_data = l_data;
106  m_size = p_size;
107  }
108  }
T min_t(const T &item1, const T &item2)
Definition: primitives.h:556
t_size m_size
Definition: alloc.h:134
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
Definition: primitives.h:611
t_item * m_data
Definition: alloc.h:133

Field Documentation

template<typename t_item >
t_item* pfc::alloc_simple< t_item >::m_data
private

Definition at line 133 of file alloc.h.

template<typename t_item >
t_size pfc::alloc_simple< t_item >::m_size
private

Definition at line 134 of file alloc.h.


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