mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-16 00:34:19 +00:00
This commit is contained in:
parent
3b59053b2c
commit
64ae185d39
1 changed files with 16 additions and 14 deletions
|
|
@ -70,8 +70,7 @@ protected:
|
|||
/** Destructor. */
|
||||
~ArrayAllocationBase() throw()
|
||||
{
|
||||
if (elements != 0)
|
||||
juce_free (elements);
|
||||
delete[] elements;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -86,23 +85,26 @@ protected:
|
|||
{
|
||||
if (numAllocated != numElements)
|
||||
{
|
||||
numAllocated = numElements;
|
||||
|
||||
if (numElements > 0)
|
||||
{
|
||||
if (elements == 0)
|
||||
elements = (ElementType*) juce_malloc (sizeof (ElementType) * numElements);
|
||||
else
|
||||
elements = (ElementType*) juce_realloc (elements, sizeof (ElementType) * numElements);
|
||||
ElementType* const newElements = new ElementType [numElements];
|
||||
|
||||
const int itemsToRetain = jmin (numElements, numAllocated);
|
||||
|
||||
for (int i = 0; i < itemsToRetain; ++i)
|
||||
newElements[i] = elements[i];
|
||||
|
||||
delete[] elements;
|
||||
elements = newElements;
|
||||
|
||||
}
|
||||
else
|
||||
else if (elements != 0)
|
||||
{
|
||||
if (elements != 0)
|
||||
{
|
||||
juce_free (elements);
|
||||
elements = 0;
|
||||
}
|
||||
delete[] elements;
|
||||
elements = 0;
|
||||
}
|
||||
|
||||
numAllocated = numElements;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue