What I mean is that when you declare a struct with a pointer as a member something random goes in there, that is foo.pointer has some value. If you force foo.pointer = NULL then realloc acts like malloc and everything is hunky dory. If you don’t, then all bets are off and you can try and realloc some chunk of memory that you do not own. On the mac (with clang), NOT explicitly setting it to NULL works without for this particular case. On Linux it segfaults. So the fix is to use the C API as it was intended to be used, i.e.
1) declare your image
ISMRMRD_image im;
2) call the init function on it to make sure the header is initialized and the pointers are set to NULL
ismrmrd_init_image(&im);
3) use it
It is possible that this example may have never worked on linux.
BTW, This is a C-API only issue. It’s C, you have a gun and you can blow off both your feet. In the C++ API, we call init in the constructor, so this can never happen.
-SI
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ismrmrd/03DCD916-81E8-4C85-A5EC-637502F151FA%40gmail.com.