Browse Source

Cleanup; Return bool on HeapBlock allocating functions

tags/1.9.8
falkTX 7 years ago
parent
commit
53fcdbc303
5 changed files with 13 additions and 27 deletions
  1. +12
    -14
      source/modules/water/memory/HeapBlock.h
  2. +0
    -3
      source/modules/water/text/CharacterFunctions.h
  3. +1
    -3
      source/modules/water/text/String.h
  4. +0
    -2
      source/modules/water/water.h
  5. +0
    -5
      source/modules/water/xml/XmlElement.h

+ 12
- 14
source/modules/water/memory/HeapBlock.h View File

@@ -31,7 +31,7 @@
namespace water {
#if ! (defined (DOXYGEN) || JUCE_EXCEPTIONS_DISABLED)
#if ! JUCE_EXCEPTIONS_DISABLED
namespace HeapBlockHelper
{
template <bool shouldThrow>
@@ -219,34 +219,37 @@ public:
The data that is allocated will be freed when this object is deleted, or when you
call free() or any of the allocation methods.
*/
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
bool malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
std::free (data);
data = static_cast<ElementType*> (std::malloc (newNumElements * elementSize));
throwOnAllocationFailure();
return data != nullptr;
}
/** Allocates a specified amount of memory and clears it.
This does the same job as the malloc() method, but clears the memory that it allocates.
*/
void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
bool calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
std::free (data);
data = static_cast<ElementType*> (std::calloc (newNumElements, elementSize));
throwOnAllocationFailure();
return data != nullptr;
}
/** Allocates a specified amount of memory and optionally clears it.
This does the same job as either malloc() or calloc(), depending on the
initialiseToZero parameter.
*/
void allocate (const size_t newNumElements, bool initialiseToZero)
bool allocate (const size_t newNumElements, bool initialiseToZero)
{
std::free (data);
data = static_cast<ElementType*> (initialiseToZero
? std::calloc (newNumElements, sizeof (ElementType))
: std::malloc (newNumElements * sizeof (ElementType)));
throwOnAllocationFailure();
return data != nullptr;
}
/** Re-allocates a specified amount of memory.
@@ -254,11 +257,11 @@ public:
The semantics of this method are the same as malloc() and calloc(), but it
uses realloc() to keep as much of the existing data as possible.
*/
void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
bool realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
data = static_cast<ElementType*> (data == nullptr ? std::malloc (newNumElements * elementSize)
: std::realloc (data, newNumElements * elementSize));
throwOnAllocationFailure();
return data != nullptr;
}
/** Frees any currently-allocated data.
@@ -303,11 +306,6 @@ private:
HeapBlockHelper::ThrowOnFail<throwOnFailure>::checkPointer (data);
#endif
}
#if ! (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD))
CARLA_DECLARE_NON_COPY_CLASS (HeapBlock)
JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point!
#endif
};
}


+ 0
- 3
source/modules/water/text/CharacterFunctions.h View File

@@ -30,9 +30,6 @@
#include "../memory/Memory.h"
/** This macro will be set to 1 if the compiler's native wchar_t is an 8-bit type. */
#define JUCE_NATIVE_WCHAR_IS_UTF8 1
namespace water {
/** A platform-independent 32-bit unicode character type. */


+ 1
- 3
source/modules/water/text/String.h View File

@@ -814,9 +814,7 @@ public:
here because of the popular unrest that was stirred-up when I tried to remove it...
If you're really determined to use it, at least make sure that you never, ever,
pass any String objects to it as parameters. And bear in mind that internally, depending
on the platform, it may be using wchar_t or char character types, so that even string
literals can't be safely used as parameters if you're writing portable code.
pass any String objects to it as parameters.
*/
static String formatted (const String formatString, ... );


+ 0
- 2
source/modules/water/water.h View File

@@ -74,8 +74,6 @@
#define JUCE_DELETED_FUNCTION
#endif
#define JUCE_PREVENT_HEAP_ALLOCATION CARLA_PREVENT_HEAP_ALLOCATION
#define NEEDS_TRANS(x) (x)
//==============================================================================


+ 0
- 5
source/modules/water/xml/XmlElement.h View File

@@ -762,11 +762,6 @@ private:
void getChildElementsAsArray (XmlElement**) const noexcept;
void reorderChildElements (XmlElement**, int) noexcept;
XmlAttributeNode* getAttribute (StringRef) const noexcept;
// Sigh.. L"" or _T("") string literals are problematic in general, and really inappropriate
// for XML tags. Use a UTF-8 encoded literal instead, or if you're really determined to use
// UTF-16, cast it to a String and use the other constructor.
XmlElement (const wchar_t*) JUCE_DELETED_FUNCTION;
};
}


Loading…
Cancel
Save