7 static void raw_free(
void * p_block)
throw() {free(p_block);}
10 if (p_size == 0) {
raw_free(p_ptr);
return NULL;}
11 else if (p_ptr == NULL)
return raw_malloc(p_size);
16 if (p_block == NULL)
return p_size == 0;
18 if (p_size == 0)
return false;
19 return _expand(p_block,p_size) != NULL;
27 return pfc::mul_safe_t<std::bad_alloc,t_size>(p_width,
sizeof(
T));
32 return reinterpret_cast<T*
>(
raw_malloc(calc_array_width<T>(p_size)));
37 raw_free(reinterpret_cast<void*>(p_block));
42 return reinterpret_cast<T*
>(
raw_realloc(p_block,calc_array_width<T>(p_size)));
51 template<
typename t_exception,
typename t_
int>
53 t_int newval = p_val << p_shift;
54 if (newval >> p_shift != p_val)
throw t_exception();
64 const t_item &
operator[](
t_size p_index)
const {
throw pfc::exception_not_implemented();}
73 const t_item *
get_ptr()
const {
throw pfc::exception_not_implemented();}
74 t_item *
get_ptr() {
throw pfc::exception_not_implemented();}
77 void move_from(t_self &) {
throw pfc::exception_not_implemented();}
79 const t_self &
operator=(
const t_self &) {
throw pfc::exception_not_implemented();}
80 alloc_dummy(
const t_self&) {
throw pfc::exception_not_implemented();}
83 template<
typename t_item>
85 return p_pointer >=
reinterpret_cast<const void*
>(p_buffer) && p_pointer < reinterpret_cast<const void*>(p_buffer + p_buffer_size);
96 t_item * l_data = NULL;
97 if (p_size > 0) l_data =
new t_item[p_size];
130 const t_self &
operator=(
const t_self &) {
throw pfc::exception_not_implemented();}
145 PFC_ASSERT(p_size <= p_size_total);
176 const t_self &
operator=(
const t_self &) {
throw pfc::exception_not_implemented();}
187 }
else if (p_size <
m_size) {
198 PFC_ASSERT(
m_size <= p_size );
207 t_item * newbuffer = pfc::__raw_malloc_t<t_item>(p_size);
237 }
else if (p_size <
m_size) {
261 const t_self &
operator=(
const t_self &) {
throw pfc::exception_not_implemented();}
272 }
else if (p_size <
m_size) {
282 PFC_ASSERT(
m_size <= p_size );
290 t_item * newbuffer = pfc::__raw_malloc_t<t_item>(p_size);
331 const t_self &
operator=(
const t_self&) {
throw pfc::exception_not_implemented();}
343 if (size_base == 0) size_base = 1;
344 while(size_base < p_size) {
345 size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
347 while(size_base >> 2 > p_size) {
350 m_data.set_size(p_size,size_base);
367 alloc_fast(
const t_self &) {
throw pfc::exception_not_implemented();}
368 const t_self &
operator=(
const t_self&) {
throw pfc::exception_not_implemented();}
379 if (size_base == 0) size_base = 1;
380 while(size_base < p_size) {
381 size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
383 m_data.set_size(p_size,size_base);
389 if (size_base == 0) size_base = 1;
390 while(size_base < p_size) {
391 size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
411 const t_self &
operator=(
const t_self&) {
throw pfc::exception_not_implemented();}
417 template<
typename t_item>
class alloc {
425 if (p_size > p_width)
throw pfc::exception_overflow();
426 else if (p_size >
m_size) {
429 }
else if (p_size <
m_size) {
442 const t_item *
get_ptr()
const {
return reinterpret_cast<const t_item*
>(&
m_array);}
453 const size_t count = other.
get_size();
455 for(
size_t w = 0; w < count; ++w) this->
get_ptr()[w] = other.
get_ptr()[w];
458 alloc(
const t_self&) {
throw pfc::exception_not_implemented();}
459 const t_self&
operator=(
const t_self&) {
throw pfc::exception_not_implemented();}
468 template<
typename t_item>
class alloc {
474 if (p_size > p_width) {
485 if (p_index < p_width)
return m_fixed[p_index];
491 if (p_index < p_width)
return m_fixed[p_index];
498 if (p_size > p_width)
m_variable.prealloc(p_size - p_width);
510 alloc(
const t_self&) {
throw pfc::exception_not_implemented();}
511 const t_self&
operator=(
const t_self&) {
throw pfc::exception_not_implemented();}
524 #if 0//not working (compiler bug?)
532 template<t_size p_w
idth,
template<
typename>
class t_alloc,
typename t_item>
const t_item * get_ptr() const
void set_size(t_size p_size)
const t_item * get_ptr() const
bool is_ptr_owned(const void *p_item) const
alloc_fast_aggressive< t_item > t_self
void set_size(t_size p_size, t_size p_size_total)
void resize_content(t_size p_size)
static void raw_free(void *p_block)
alloc_simple(const t_self &)
void prealloc(t_size p_size)
bool is_ptr_owned(const void *p_item) const
void set_size(t_size p_size)
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
t_uint8 m_array[sizeof(t_item[p_width])]
T min_t(const T &item1, const T &item2)
__array_fast_helper_t< t_item > m_data
alloc_fast(const t_self &)
const t_item * get_ptr() const
t_type replace_null_t(t_type &p_var)
t_size get_size_total() const
void move_from(t_self &other)
void set_size(t_size p_size)
T * __raw_malloc_t(t_size p_size)
const t_item & operator[](t_size p_index) const
void set_size(t_size p_size)
const t_self & operator=(const t_self &)
const t_item & operator[](t_size p_index) const
alloc_fast< t_item > t_self
void resize_content(t_size p_size)
__array_lite_helper_t< t_item > m_content
const t_item & operator[](t_size p_index) const
void move_from(t_self &other)
const t_item * get_ptr() const
t_item & operator[](t_size p_index)
void move_from(t_self &other)
t_item & operator[](t_size n)
bool is_ptr_owned(const void *p_item) const
t_item & operator[](t_size p_index)
t_int safe_shift_left_t(t_int p_val, t_size p_shift=1)
void move_from(t_self &other)
t_type * __unsafe__in_place_constructor_array_copy_t(t_type *p_items, t_size p_count, const t_copy *p_copyfrom)
void __raw_free_t(T *p_block)
bool is_ptr_owned(const void *p_item) const
t_alloc< t_item > m_variable
const t_item & operator[](t_size p_index) const
void move_from(t_self &other)
const t_item * get_ptr() const
const t_item & operator[](t_size n) const
void move_from(t_self &other)
t_size calc_array_width(t_size p_width)
alloc_dummy(const t_self &)
void set_size(t_size p_size)
t_item & operator[](t_size p_index)
bool is_ptr_owned(const void *p_item) const
const t_item & operator[](t_size p_index) const
alloc_dummy< t_item > t_self
__array_fast_helper_t< t_item > t_self
void move_from(t_self &other)
t_item & operator[](t_size p_index)
const t_self & operator=(const t_self &)
const t_item * get_ptr() const
static void * raw_malloc(t_size p_size)
T * new_ptr_check_t(T *p_ptr)
const t_item * get_ptr() const
static bool raw_realloc_inplace(void *p_block, t_size p_size)
bool __raw_realloc_inplace_t(T *p_block, t_size p_size)
alloc_standard< t_item > t_self
const t_self & operator=(const t_self &)
alloc_fast_aggressive(const t_self &)
T * __raw_realloc_t(T *p_block, t_size p_size)
const t_self & operator=(const t_self &)
bool is_ptr_owned(const void *p_item) const
const t_item & operator[](t_size p_index) const
const t_self & operator=(const t_self &)
void prealloc(t_size p_size)
alloc_standard(const t_self &)
t_item & operator[](t_size p_index)
bool is_ptr_owned(const void *p_item) const
t_item & operator[](t_size p_index)
const t_self & operator=(const t_self &)
const t_self & operator=(const t_self &)
void __unsafe__in_place_constructor_t(t_type &p_item)
void resize_storage(t_size p_size)
const t_item & operator[](t_size p_index) const
t_type * __unsafe__in_place_constructor_array_t(t_type *p_items, t_size p_count)
alloc_fixed< p_width >::template alloc< t_item > m_fixed
Simple inefficient fully portable allocator.
void set_size(t_size p_size)
void set_size(t_size p_size)
__array_lite_helper_t< t_item > t_self
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
void move_from(t_self &other)
const t_item * get_ptr() const
__array_fast_helper_t< t_item > m_data
alloc_simple< t_item > t_self
static void * raw_realloc(void *p_ptr, t_size p_size)
const t_item & operator[](t_size p_index) const
void set_size(t_size p_size)
t_item & operator[](t_size p_index)
bool is_ptr_owned(const void *p_item) const
bool is_ptr_owned(const void *p_item) const
t_item & operator[](t_size p_index)
__array_fast_helper_t(const t_self &)
const t_self & operator=(const t_self &)
void prealloc(t_size p_size)
bool is_pointer_in_range(const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
const t_self & operator=(const t_self &)
__array_lite_helper_t(const t_self &)
void resize_storage(t_size p_size)