Why does my Array enlarge with each call to size? [SOLVED]


#1

With the code . . .

Array< var > * bandsData = ipData[bandArrayID].getArray(); DBG(bandsData->size()) DBG(bandsData->size()) DBG(bandsData->size()) DBG(bandsData->size()) DBG(bandsData->size())

I get the following output to the console (the array has size 3). .

JUCE v2.0.39 3 51 12597 12597 12597

What on earth can be happening here ?!


#2

When you call ipData[bandArrayID], it returns a temporary var object. You then get the array pointer from that object, the object is deleted, and then you use the now-dangling array.


#3

DoH! Thanks. All is right with the world once more