mirror of
https://github.com/sfilippone/psblas3.git
synced 2026-10-20 12:52:14 +00:00
Fixes for memory leaks in the C interface
This commit is contained in:
@@ -979,8 +979,9 @@ contains
|
||||
call psb_close_context(psb_mesg_queue,ctxt)
|
||||
end if
|
||||
!if ((ctxt /= mpi_comm_null).and.(ctxt /= mpi_comm_world)) then
|
||||
if (allocated(ctxt%ctxt)) then
|
||||
if (ctxt%ctxt /= mpi_comm_world)call mpi_comm_Free(ctxt%ctxt,info)
|
||||
if (allocated(ctxt%ctxt)) then
|
||||
!write(0,*) ctxt%ctxt,mpi_comm_world,mpi_comm_null
|
||||
if ((ctxt%ctxt /= mpi_comm_world).and.(ctxt%ctxt /= mpi_comm_null)) call mpi_comm_Free(ctxt%ctxt,info)
|
||||
end if
|
||||
|
||||
if (close_) call mpi_finalize(info)
|
||||
|
||||
@@ -93,6 +93,8 @@ contains
|
||||
|
||||
call psb_gefree(xp,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(xp,stat=info)
|
||||
res = min(0,info)
|
||||
xh%item = c_null_ptr
|
||||
|
||||
return
|
||||
@@ -264,6 +266,7 @@ contains
|
||||
|
||||
call psb_spfree(ap,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(ap,stat=info)
|
||||
mh%item=c_null_ptr
|
||||
return
|
||||
end function psb_c_cspfree
|
||||
|
||||
@@ -102,6 +102,9 @@ contains
|
||||
type(psb_ctxt_type), pointer :: ctxt
|
||||
ctxt => psb_c2f_ctxt(cctxt)
|
||||
call psb_exit(ctxt,close=.false.)
|
||||
|
||||
deallocate(ctxt,stat=info)
|
||||
|
||||
return
|
||||
end subroutine psb_c_exit_ctxt
|
||||
|
||||
@@ -110,9 +113,12 @@ contains
|
||||
type(psb_c_object_type), value :: cctxt
|
||||
|
||||
type(psb_ctxt_type), pointer :: ctxt
|
||||
integer(psb_ipk_) :: info
|
||||
|
||||
ctxt => psb_c2f_ctxt(cctxt)
|
||||
|
||||
call psb_exit(ctxt)
|
||||
deallocate(ctxt,stat=info)
|
||||
cctxt%item = c_null_ptr
|
||||
return
|
||||
end subroutine psb_c_exit
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ contains
|
||||
|
||||
call psb_gefree(xp,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(xp,stat=info)
|
||||
res = min(0,info)
|
||||
xh%item = c_null_ptr
|
||||
|
||||
return
|
||||
@@ -264,6 +266,7 @@ contains
|
||||
|
||||
call psb_spfree(ap,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(ap,stat=info)
|
||||
mh%item=c_null_ptr
|
||||
return
|
||||
end function psb_c_dspfree
|
||||
|
||||
@@ -93,6 +93,8 @@ contains
|
||||
|
||||
call psb_gefree(xp,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(xp,stat=info)
|
||||
res = min(0,info)
|
||||
xh%item = c_null_ptr
|
||||
|
||||
return
|
||||
@@ -264,6 +266,7 @@ contains
|
||||
|
||||
call psb_spfree(ap,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(ap,stat=info)
|
||||
mh%item=c_null_ptr
|
||||
return
|
||||
end function psb_c_sspfree
|
||||
|
||||
@@ -93,6 +93,8 @@ contains
|
||||
|
||||
call psb_gefree(xp,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(xp,stat=info)
|
||||
res = min(0,info)
|
||||
xh%item = c_null_ptr
|
||||
|
||||
return
|
||||
@@ -264,6 +266,7 @@ contains
|
||||
|
||||
call psb_spfree(ap,descp,info)
|
||||
res = min(0,info)
|
||||
deallocate(ap,stat=info)
|
||||
mh%item=c_null_ptr
|
||||
return
|
||||
end function psb_c_zspfree
|
||||
|
||||
@@ -111,9 +111,9 @@ contains
|
||||
end if
|
||||
|
||||
call psb_precfree(precp, info)
|
||||
|
||||
res = min(info,0)
|
||||
|
||||
deallocate(precp,stat=info)
|
||||
ph%item = c_null_ptr
|
||||
end function psb_c_cprecfree
|
||||
|
||||
|
||||
|
||||
@@ -111,9 +111,9 @@ contains
|
||||
end if
|
||||
|
||||
call psb_precfree(precp, info)
|
||||
|
||||
res = min(info,0)
|
||||
|
||||
deallocate(precp,stat=info)
|
||||
ph%item = c_null_ptr
|
||||
end function psb_c_dprecfree
|
||||
|
||||
|
||||
|
||||
@@ -111,9 +111,9 @@ contains
|
||||
end if
|
||||
|
||||
call psb_precfree(precp, info)
|
||||
|
||||
res = min(info,0)
|
||||
|
||||
deallocate(precp,stat=info)
|
||||
ph%item = c_null_ptr
|
||||
end function psb_c_sprecfree
|
||||
|
||||
|
||||
|
||||
@@ -111,9 +111,9 @@ contains
|
||||
end if
|
||||
|
||||
call psb_precfree(precp, info)
|
||||
|
||||
res = min(info,0)
|
||||
|
||||
deallocate(precp,stat=info)
|
||||
ph%item = c_null_ptr
|
||||
end function psb_c_zprecfree
|
||||
|
||||
|
||||
|
||||
@@ -385,6 +385,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
/* Clean up memory */
|
||||
if ((info=psb_c_dprecfree(ph))!=0) {
|
||||
fprintf(stderr,"From dprecfree: %d\nBailing out\n",info);
|
||||
psb_c_abort(*cctxt);
|
||||
}
|
||||
if ((info=psb_c_dgefree(xh,cdh))!=0) {
|
||||
fprintf(stderr,"From dgefree: %d\nBailing out\n",info);
|
||||
psb_c_abort(*cctxt);
|
||||
@@ -397,6 +401,10 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr,"From dgefree: %d\nBailing out\n",info);
|
||||
psb_c_abort(*cctxt);
|
||||
}
|
||||
if ((info=psb_c_dspfree(ah,cdh))!=0) {
|
||||
fprintf(stderr,"From dspfree: %d\nBailing out\n",info);
|
||||
psb_c_abort(*cctxt);
|
||||
}
|
||||
|
||||
if ((info=psb_c_cdfree(cdh))!=0) {
|
||||
fprintf(stderr,"From cdfree: %d\nBailing out\n",info);
|
||||
@@ -408,12 +416,15 @@ int main(int argc, char *argv[])
|
||||
free(ph);
|
||||
free(xh);
|
||||
free(bh);
|
||||
free(rh);
|
||||
free(ah);
|
||||
free(cdh);
|
||||
|
||||
|
||||
/* further cleanup */
|
||||
free(vl);
|
||||
//if (iam == 0) fprintf(stderr,"program completed successfully\n");
|
||||
|
||||
psb_c_barrier(*cctxt);
|
||||
psb_c_exit(*cctxt);
|
||||
free(cctxt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user