Ok the exact error message is -
prog_name(35122) malloc :
*** error for object 0xbfffa878: non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
OK .. off the bat, that doesn't help that much. I would suggest that you take Tommy Gunn's advice and remove the casts to your malloc() and calloc() function calls.