26#if ! (DOXYGEN || JUCE_EXCEPTIONS_DISABLED)
29 template <
bool shouldThrow>
85template <
class ElementType,
bool throwOnFailure = false>
89 template <
class OtherElementType>
90 using AllowConversion =
typename std::enable_if<std::is_base_of<typename std::remove_pointer<ElementType>::type,
91 typename std::remove_pointer<OtherElementType>::type>
::value>
::type;
110 template <typename SizeType, std::enable_if_t<std::is_convertible<SizeType, int>::value,
int> = 0>
112 :
data (static_cast<ElementType*> (
std::
malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
122 template <typename SizeType, std::enable_if_t<std::is_convertible<SizeType, int>::value,
int> = 0>
124 :
data (static_cast<ElementType*> (initialiseToZero
125 ?
std::
calloc (static_cast<size_t> (numElements), sizeof (ElementType))
126 :
std::
malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
143 other.data =
nullptr;
149 std::swap (
data, other.data);
157 template <
class OtherElementType,
bool otherThrowOnFailure,
typename = AllowConversion<OtherElementType>>
159 :
data (
reinterpret_cast<ElementType*
> (other.data))
161 other.data =
nullptr;
168 template <
class OtherElementType,
bool otherThrowOnFailure,
typename = AllowConversion<OtherElementType>>
172 data =
reinterpret_cast<ElementType*
> (other.data);
173 other.data =
nullptr;
182 inline operator ElementType*()
const noexcept {
return data; }
200 inline operator void*()
const noexcept {
return static_cast<void*
> (
data); }
206 inline operator const void*()
const noexcept {
return static_cast<const void*
> (
data); }
218 template <
typename IndexType>
219 ElementType& operator[] (IndexType index)
const noexcept {
return data [index]; }
224 template <
typename IndexType>
225 ElementType* operator+ (IndexType index)
const noexcept {
return data + index; }
231 inline bool operator== (
const ElementType* otherPointer)
const noexcept {
return otherPointer ==
data; }
236 inline bool operator!= (
const ElementType* otherPointer)
const noexcept {
return otherPointer !=
data; }
251 template <
typename SizeType>
252 void malloc (SizeType newNumElements,
size_t elementSize =
sizeof (ElementType))
255 data =
static_cast<ElementType*
> (std::malloc (
static_cast<size_t> (newNumElements) * elementSize));
262 template <
typename SizeType>
263 void calloc (SizeType newNumElements,
const size_t elementSize =
sizeof (ElementType))
266 data =
static_cast<ElementType*
> (std::calloc (
static_cast<size_t> (newNumElements), elementSize));
274 template <
typename SizeType>
275 void allocate (SizeType newNumElements,
bool initialiseToZero)
278 data =
static_cast<ElementType*
> (initialiseToZero
279 ? std::calloc (
static_cast<size_t> (newNumElements),
sizeof (ElementType))
280 : std::malloc (
static_cast<size_t> (newNumElements) *
sizeof (ElementType)));
289 template <
typename SizeType>
290 void realloc (SizeType newNumElements,
size_t elementSize =
sizeof (ElementType))
292 data =
static_cast<ElementType*
> (
data ==
nullptr ? std::malloc (
static_cast<size_t> (newNumElements) * elementSize)
293 : std::realloc (
data,
static_cast<size_t> (newNumElements) * elementSize));
309 template <
bool otherBlockThrows>
312 std::swap (
data, other.data);
319 template <
typename SizeType>
320 void clear (SizeType numElements)
noexcept
322 zeromem (
data,
sizeof (ElementType) *
static_cast<size_t> (numElements));
334 #if JUCE_EXCEPTIONS_DISABLED
341 template <
class OtherElementType,
bool otherThrowOnFailure>
344 #if ! (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD))
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
char * data
Definition juce_HeapBlock.h:330
~HeapBlock()
Definition juce_HeapBlock.h:134
HeapBlock(SizeType numElements)
Definition juce_HeapBlock.h:111
HeapBlock(HeapBlock< OtherElementType, otherThrowOnFailure > &&other) noexcept
Definition juce_HeapBlock.h:158
ElementType Type
Definition juce_HeapBlock.h:326
void clear(SizeType numElements) noexcept
Definition juce_HeapBlock.h:320
void swapWith(HeapBlock< ElementType, otherBlockThrows > &other) noexcept
Definition juce_HeapBlock.h:310
typename std::enable_if< std::is_base_of< typename std::remove_pointer< ElementType >::type, typename std::remove_pointer< OtherElementType >::type >::value >::type AllowConversion
Definition juce_HeapBlock.h:90
void malloc(SizeType newNumElements, size_t elementSize=sizeof(char))
Definition juce_HeapBlock.h:252
friend class HeapBlock
Definition juce_HeapBlock.h:342
HeapBlock(HeapBlock &&other) noexcept
Definition juce_HeapBlock.h:140
void throwOnAllocationFailure() const
Definition juce_HeapBlock.h:332
ElementType * get() const noexcept
Definition juce_HeapBlock.h:188
ElementType * getData() const noexcept
Definition juce_HeapBlock.h:194
void allocate(SizeType newNumElements, bool initialiseToZero)
Definition juce_HeapBlock.h:275
HeapBlock(SizeType numElements, bool initialiseToZero)
Definition juce_HeapBlock.h:123
void realloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Definition juce_HeapBlock.h:290
void free() noexcept
Definition juce_HeapBlock.h:300
ElementType * operator->() const noexcept
Definition juce_HeapBlock.h:212
void calloc(SizeType newNumElements, const size_t elementSize=sizeof(char))
Definition juce_HeapBlock.h:263
static PuglViewHint int value
Definition pugl.h:1708
JSAMPIMAGE data
Definition jpeglib.h:945
Definition juce_HeapBlock.h:28
Definition carla_juce.cpp:31
void zeromem(void *memory, size_t numBytes) noexcept
Definition juce_Memory.h:28
Definition juce_Uuid.h:141
#define true
Definition ordinals.h:82
static void checkPointer(void *data)
Definition juce_HeapBlock.h:33
Definition juce_HeapBlock.h:30
static void checkPointer(void *)
Definition juce_HeapBlock.h:30
#define const
Definition zconf.h:137