I'm wondering why a released CFDataRef returns a valid value using
CFDataGetBytePtr?
Does CFRelease actually deallocate/free memory which is allocated and
copied from source memory?
If not, where and how do I free the memory that the dataRef has been
holding?
int main ()
{
const char* kMyName = "Norio Ota";
size_t len = strlen (kMyName);
char * newString, *dStr;
CFDataRef data;
newString = (char*) malloc (len + 1);
memcpy (newString, kMyName, len);
newString[len] = '\0';
data = CFDataCreate (kCFAllocatorDefault, newString, len +1);
CFShow (data);
fprintf (stderr, "newString is %s\n", newString);
free (newString);
<CFData 0x11011d0 [0xa01c00e0]>{length = 10, capacity = 10, bytes =
0x4e6f72696f204f746100}
newString is Norio Ota
freed newString is
<CFData 0x11011d0 [0xa01c00e0]>{length = 10, capacity = 10, bytes =
0x4e6f72696f204f746100}
after releasing, stored newString is Norio Ota
As you can see, despite the data was released before being called
CFDataGetBytePtr, it returns a value which seems to be valid.
Thanks,
Norio
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden