Setting OwnedArray elements to NULL


#1

Consider this code:

OwnedArray<int> foo;
int             *int_ptr = new int(1);

foo.add(int_ptr);
foo.set(0,NULL,false);

At the end of this I assume foo[0] is NULL, but it’s not.

There are no doubt a bunch of different ways to change OwnedArray::set to handle this case. One way that works for me is removing the “else” from line 362 of juce_OwnedArray.h (svn #284).

Please consider changing OwnedArray::set to support this behavior.

Thanks much.

-DB


#2

Wow - good catch there! Thanks, yes, I’ll make sure that gets sorted out.


#3

Great. I see a new version of juce_OwnedArray.h in the repository. Works for me.

Thanks.

-DB