26#ifndef WATER_HEAPBLOCK_H_INCLUDED
27#define WATER_HEAPBLOCK_H_INCLUDED
75template <
class ElementType>
102 inline operator ElementType*()
const noexcept {
return data; }
120 inline operator void*()
const noexcept {
return static_cast<void*
> (
data); }
126 inline operator const void*()
const noexcept {
return static_cast<const void*
> (
data); }
138 template <
typename IndexType>
139 inline ElementType&
operator[] (IndexType index)
const noexcept {
return data [index]; }
144 template <
typename IndexType>
145 inline ElementType*
operator+ (IndexType index)
const noexcept {
return data + index; }
151 inline bool operator== (
const ElementType*
const otherPointer)
const noexcept {
return otherPointer ==
data; }
156 inline bool operator!= (
const ElementType*
const otherPointer)
const noexcept {
return otherPointer !=
data; }
171 bool malloc (
const size_t newNumElements,
const size_t elementSize =
sizeof (ElementType))
noexcept
174 data =
static_cast<ElementType*
> (std::malloc (newNumElements * elementSize));
176 return data !=
nullptr;
182 bool calloc (
const size_t newNumElements,
const size_t elementSize =
sizeof (ElementType))
noexcept
185 data =
static_cast<ElementType*
> (std::calloc (newNumElements, elementSize));
187 return data !=
nullptr;
194 bool allocate (
const size_t newNumElements,
bool initialiseToZero)
noexcept
197 data =
static_cast<ElementType*
> (initialiseToZero
198 ? std::calloc (newNumElements,
sizeof (ElementType))
199 : std::malloc (newNumElements *
sizeof (ElementType)));
201 return data !=
nullptr;
209 bool realloc (
const size_t newNumElements,
const size_t elementSize =
sizeof (ElementType))
noexcept
211 data =
static_cast<ElementType*
> (
data ==
nullptr ? std::malloc (newNumElements * elementSize)
212 : std::realloc (
data, newNumElements * elementSize));
213 return data !=
nullptr;
230 std::swap (
data, other.data);
237 void clear (
size_t numElements)
noexcept
239 zeromem (
data,
sizeof (ElementType) * numElements);
245 ElementType*
const r =
data;
#define CARLA_DECLARE_NON_COPYABLE(ClassName)
Definition CarlaDefines.h:242
#define noexcept
Definition DistrhoDefines.h:72
ElementType * data
Definition HeapBlock.h:255
const ElementType * getConstData() const noexcept
Definition HeapBlock.h:114
bool operator==(const ElementType *const otherPointer) const noexcept
Definition HeapBlock.h:151
bool malloc(const size_t newNumElements, const size_t elementSize=sizeof(ElementType)) noexcept
Definition HeapBlock.h:171
ElementType & operator[](IndexType index) const noexcept
Definition HeapBlock.h:139
ElementType * getData() const noexcept
Definition HeapBlock.h:108
ElementType * operator+(IndexType index) const noexcept
Definition HeapBlock.h:145
HeapBlock() noexcept
Definition HeapBlock.h:85
void clear(size_t numElements) noexcept
Definition HeapBlock.h:237
bool calloc(const size_t newNumElements, const size_t elementSize=sizeof(ElementType)) noexcept
Definition HeapBlock.h:182
void swapWith(HeapBlock< ElementType > &other) noexcept
Definition HeapBlock.h:228
ElementType Type
Definition HeapBlock.h:251
bool allocate(const size_t newNumElements, bool initialiseToZero) noexcept
Definition HeapBlock.h:194
bool operator!=(const ElementType *const otherPointer) const noexcept
Definition HeapBlock.h:156
ElementType * operator->() const noexcept
Definition HeapBlock.h:132
bool realloc(const size_t newNumElements, const size_t elementSize=sizeof(ElementType)) noexcept
Definition HeapBlock.h:209
~HeapBlock() noexcept
Definition HeapBlock.h:92
ElementType * release() noexcept
Definition HeapBlock.h:243
void free() noexcept
Definition HeapBlock.h:219
Definition AudioSampleBuffer.h:33
void zeromem(void *memory, size_t numBytes) noexcept
Definition Memory.h:37
int r
Definition crypt.c:458
#define const
Definition zconf.h:137