Simple question. I have a char pointer in a struct. When I try to free it, I get the following error at run time:
a.out(1186) malloc: *** error for object 0x1ffc: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Why?
Code:typedef struct foo { char *str; } foo; void foo_free(foo *f) { free(f->str); } int main(int argc, char **argv) { foo *f = malloc(sizeof(foo)); f->str = "foo"; foo_free(f); return 0; }