tags:

views:

32

answers:

1

I am only having this problem when running 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?

+3  A: 

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.

Paul
I completely agree. To detect this sort of thing it would probably good to run your code with valgrind.
Jens Gustedt