Re: malloc in obj-c/cocoa
Re: malloc in obj-c/cocoa
- Subject: Re: malloc in obj-c/cocoa
- From: Glenn Andreas <email@hidden>
- Date: Fri, 6 Feb 2004 18:51:17 -0600
At 11:47 PM +0000 2/6/04, Ben Dougall wrote:
On Friday, February 6, 2004, at 11:33 pm, Jens Bauer wrote:
Hi Ben,
On Friday, Feb 6, 2004, at 22:14 Europe/Copenhagen, Ben Dougall wrote:
i'm malloc'ing little bits of memory, passing the pointers round
and stuff. getting this error:
*** malloc[22753]: error for object 0x7dbd0: Incorrect checksum
for freed object - object was probably modified after being freed;
break at szone_error
I've seen this ever so often. It's a memory overwrite.
Try disabling your code...
PositionPtr posp;
posp = (PositionPtr) malloc( i ));
while( i >= 0 ) {
// *(posp + i) = *(Buffer + i);
i--;
}
and see if the crash occurs.
If it doesn't, you know that this *is* the place it happens.
yup, you're absolutely right. haven't quite worked out exactly
what's happening yet but should be able to now.
What is "PositionPtr" typed as? If it is something like:
typedef int *PositionPtr;
then the problem is that malloc is allocation, say, 10 bytes, when it
needs 10 * sizeof(int) bytes.
Perhaps a better thing would be something like:
posp = (PositionPtr) malloc(i * sizeof(Position));
--
Glenn Andreas email@hidden
mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.