1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00
This commit is contained in:
jules 2008-07-02 20:11:37 +00:00
parent 3b59053b2c
commit 64ae185d39

View file

@ -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;
}
}