non-aligned pointer being freed on mac
I am only having this problem when r开发者_开发知识库unning my program on a Mac; linux 64 and 32 bit are fine but on mac I get a bunch of:
*** malloc[437]: error for object 0xbfffe970:
Non-aligned pointer being freed (2)
towards the end of execution of my program where I am freeing a bunch of pointers in a data structure. Code to long to be posted but does anyone have any idea why it works fine without error on linux but not mac?
Probably just a different malloc implementation. Presumably the Mac malloc aligns to bigger boundaries and so it's spotting the pointer you're passing to free can't be correct since it has the wrong alignment
HOWEVER, it is saying that you're passing to free() a pointer that didn't come from malloc(). This is certainly a sign of a bug, and it's probably happening on all your platforms.
I experienced the same error on Mac OS X 10.7. In my case it was because I malloc'ed zero bytes.
I experienced this, because I didn't use an allocator for an array of char that held just one element when I created it. It went good for all other cases, but when the CoreFoundation array was created with an array of one char.
精彩评论