28inline void zeromem (
void* memory,
size_t numBytes)
noexcept {
memset (memory, 0, numBytes); }
31template <
typename Type>
39template <
typename Type>
40inline void deleteAndZero (Type& pointer) {
delete pointer; pointer =
nullptr; }
44template <
typename Type,
typename IntegerType>
53template <
typename Type1,
typename Type2>
64template <
typename Type>
73template <
typename Type>
87template <
typename Type>
90 static_assert (std::is_pointer_v<Type>);
91 return reinterpret_cast<Type
> (ptr);
101template <
typename Type>
104 static_assert (std::is_pointer_v<Type>);
105 return reinterpret_cast<Type
> (ptr);
112template <
typename Type,
typename IntegerType>
122template <
typename Type,
typename IntegerType>
129#if JUCE_MAC || JUCE_IOS || DOXYGEN
153#if (JUCE_COMPILER_SUPPORTS_ARC && defined (__OBJC__)) || DOXYGEN
154 #define JUCE_AUTORELEASEPOOL @autoreleasepool
156 #define JUCE_AUTORELEASEPOOL const juce::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__);
160 #define JUCE_AUTORELEASEPOOL
169#if JUCE_MSVC && (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)) && ! (JUCE_DISABLE_DLL_ALLOCATORS || DOXYGEN)
173 #define JUCE_LEAK_DETECTOR(OwnerClass) public:\
174 static void* operator new (size_t sz) { return juce::juceDLL_malloc (sz); } \
175 static void* operator new (size_t, void* p) { return p; } \
176 static void operator delete (void* p) { juce::juceDLL_free (p); } \
177 static void operator delete (void*, void*) {}
184#ifndef juce_UseDebuggingNewOperator
185 #define juce_UseDebuggingNewOperator
A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII.
Type * createCopyIfNotNull(const Type *objectToCopy)
If a pointer is non-null, this returns a new copy of the object that it points to,...
void zerostruct(Type &structure) noexcept
Overwrites a structure or object with zeros.
int getAddressDifference(Type1 *pointer1, Type2 *pointer2) noexcept
A handy function which returns the difference between any two pointers, in bytes.
Type readUnaligned(const void *srcPtr) noexcept
A handy function to read un-aligned memory without a performance penalty or bus-error.
void deleteAndZero(Type &pointer)
Delete an object pointer, and sets the pointer to null.
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
A handy function which adds a number of bytes to any type of pointer and returns the result.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
void writeUnaligned(void *dstPtr, Type value) noexcept
A handy function to write un-aligned memory without a performance penalty or bus-error.
Type * snapPointerToAlignment(Type *basePointer, IntegerType alignmentBytes) noexcept
A handy function to round up a pointer to the nearest multiple of a given number of bytes.
std::unique_ptr< T > rawToUniquePtr(T *ptr)
Converts an owning raw pointer into a unique_ptr, deriving the type of the unique_ptr automatically.
void zeromem(void *memory, size_t numBytes) noexcept
Fills a block of memory with zeros.