I try to use the code snippet from the Apple programming guide and I get EXC_BAD_ACCESS when I try to pass a pointer to a function right after malloc is executed.
(for reference: iPhone Application Programming Guide: event handling - Listing 3-6 )
This code is really simple:
CFMutableDictionaryRef touchBeginPoints;
UITouch *touch;
....
CGPoint *point = (CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch);
if (point == NULL)
{
point = (CGPoint *)malloc(sizeof(CGPoint));
CFDictionarySetValue(touchBeginPoints, touch, point);
}
Now, when the program goes into a statement if, it assigns 'output' from mallocto a variable / pointer point.
Then, when it tries to pass pointto a function CFDictionarySetValue, it resets the application with:Program received signal: "EXC_BAD_ACCESS".
- malloc point var/pointer : &point, EXC_BAD_ACCESS.
( Apple) ???
.