If you have a project that utilizes a makefile which compiles multiple files and headers, does this complicate the heap?
Specifically:
I have a main.c file which includes a header, say test.h. In test.c which is linked to test.h memory is allocated explicitly with malloc. main.ccalls the functions in test.c. For some reason, when I try to to free memory inside of the functions in test.c I always get an error:
main(65245) malloc: *** error for object 0x106d012f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
...this error occurs even though I never, not even once free any memory at all in the entire makefile stack. Obviously stdlib.h is included. What could be going on? Are there separate heaps for main.c and test.c and whenever the latter is called and the result is returned, the heap memory allocated is already freed? I'm really stumped. I can allocate and free memory in main.c without any issue. They have the same includes.