Problems in delete[] when called from fortran

Hi,
I have a library I wrote in C++ and I have fortran wrappers to call the function from fortran. I am having some problems while de-allocating the memory.

A snippet of the code for de-allocating an object is :
1
2
3
4
5
6
 printf("%d localbuffer location : %p\n",myid,localBuffer);
 fflush(stdout);
 if( localBuffer)
   delete[] localBuffer;
 printf("%d local buffer deleted\n",myid);
 fflush(stdout);


When I call this function from C, there is no problem, but while calling form FORTRAN it doesnt go to the second printf call ( it hangs and does nothing).
I realize that there might not be enough information. Please let me know what additional details might be needed and ill post them

Thanks for your help and sorry if this is not the right forum for this
You may have corrupted the heap along the way in the Fortran app.
Hmm, I am not sure. In my application I know exactly where localBuffer is allocated. And I checked the value of the pointer at the place of allocation and as shown above , I check it before deallocation. They are the same. In my library, the entire memory management is done internally. So there is no difference when called from C or FORTRAN.
Have you tried doing the allocate and then immediately doing the release to see if it still crashes? If it doesn't, you have a memory overrun somewhere.
Topic archived. No new replies allowed.