FROM : Chris Suter
DATE : Tue Feb 19 19:38:51 2008
On 19/02/2008, at 10:48 PM, Alastair Houghton wrote:
> I'm not sure what the best fix is for this. Like Chris said, one
> option would be to allow us to allocate "autoreleased" memory (in
> which case -UTF8String should probably be doing that too). Or maybe
> the GC should support interior pointers to memory allocated with
> NSAllocateCollectable()?
I'm not convinced that supporting interior pointers is the right
solution. I can imagine a situation where the pointer that's lying
around is pointing beyond the end of the array. For example, with
optimisations this might break:
for (n = 0, myPointer = myArray; n < size; ++n, ++myPointer) {
// Do something
}
// In the following the compiler could optimise this to be myPointer[-1]
doSomethingWith (myArray[size - 1]);
// No further references to myArray
DATE : Tue Feb 19 19:38:51 2008
On 19/02/2008, at 10:48 PM, Alastair Houghton wrote:
> I'm not sure what the best fix is for this. Like Chris said, one
> option would be to allow us to allocate "autoreleased" memory (in
> which case -UTF8String should probably be doing that too). Or maybe
> the GC should support interior pointers to memory allocated with
> NSAllocateCollectable()?
I'm not convinced that supporting interior pointers is the right
solution. I can imagine a situation where the pointer that's lying
around is pointing beyond the end of the array. For example, with
optimisations this might break:
for (n = 0, myPointer = myArray; n < size; ++n, ++myPointer) {
// Do something
}
// In the following the compiler could optimise this to be myPointer[-1]
doSomethingWith (myArray[size - 1]);
// No further references to myArray






Cocoa mail archive

