Browse Source

tags/2021-05-28
jules 17 years ago
parent
commit
64ae185d39
1 changed files with 16 additions and 14 deletions
  1. +16
    -14
      src/juce_core/containers/juce_ArrayAllocationBase.h

+ 16
- 14
src/juce_core/containers/juce_ArrayAllocationBase.h 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;
}
}


Loading…
Cancel
Save