Have a look at this pseudocode:
void* magicpointer = malloc(OVER_NINE_THOUSAND);
NSValue* v = [NSValue valueWithPointer:magicpointer];
[v release];
When v is released, does magicpointer get freed as well, or do I have to do that manually? I am using manual reference counting.
It doesn't get freed - NSValue is just a wrapper so you can treat arbitrary values as objects. It doesn't do anything with the wrapped pointer.
No, NSValue won't.
Sounds like you might want to use NSData, it can free it's pointer when it's released:
void* magicpointer = malloc(OVER_NINE_THOUSAND);
NSData *d = [NSData dataWithBytesNoCopy:magicpointer
length:OVER_NINE_THOUSAND
freeWhenDone:YES];
//d is autoreleased, so no need to -release it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With