File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ namespace Gint_Tools
3939 const int jby,
4040 const int kbz)
4141 {
42- int *vindex = ( int *) malloc ( GlobalC::bigpw->bxyz * sizeof ( int )) ;
42+ int *vindex = new int [ GlobalC::bigpw->bxyz ] ;
4343 int bindex=0 ;
4444 // z is the fastest,
4545 // ipart can be obtained by using a previously stored array
@@ -71,12 +71,12 @@ namespace Gint_Tools
7171 {
7272 // set the index for obtaining local potentials
7373 int * vindex = Gint_Tools::get_vindex (ncyz, ibx, jby, kbz);
74- double *vldr3 = ( double *) malloc ( GlobalC::bigpw->bxyz * sizeof ( double ));
74+ double *vldr3 = new double [ GlobalC::bigpw->bxyz ];
7575 for (int ib=0 ; ib<GlobalC::bigpw->bxyz ; ib++)
7676 {
7777 vldr3[ib]=vlocal[vindex[ib]] * dv;
7878 }
79- free ( vindex); vindex= nullptr ;
79+ delete[] vindex;
8080 return vldr3;
8181 }
8282
@@ -88,12 +88,12 @@ namespace Gint_Tools
8888 {
8989 // set the index for obtaining local potentials
9090 int * vindex = Gint_Tools::get_vindex (start_ind, ncyz);
91- double *vldr3 = ( double *) malloc ( GlobalC::bigpw->bxyz * sizeof ( double ));
91+ double *vldr3 = new double [ GlobalC::bigpw->bxyz ];
9292 for (int ib=0 ; ib<GlobalC::bigpw->bxyz ; ib++)
9393 {
9494 vldr3[ib]=vlocal[vindex[ib]] * dv;
9595 }
96- free ( vindex); vindex= nullptr ;
96+ delete[] vindex;
9797 return vldr3;
9898 }
9999
Original file line number Diff line number Diff line change @@ -243,8 +243,8 @@ namespace Gint_Tools
243243 template <typename T>
244244 Array_Pool<T>::Array_Pool(const int nr, const int nc) // Attention: uninitialized
245245 {
246- ptr_1D = (T*) malloc ( nr*nc* sizeof (T)) ;
247- ptr_2D = (T**) malloc (nr* sizeof (T*)) ;
246+ ptr_1D = new T[ nr*nc] ;
247+ ptr_2D = new T*[nr] ;
248248 for (int ir=0 ; ir<nr; ++ir)
249249 ptr_2D[ir] = &ptr_1D[ir*nc];
250250 }
@@ -254,15 +254,15 @@ namespace Gint_Tools
254254 {
255255 ptr_1D = array.ptr_1D ;
256256 ptr_2D = array.ptr_2D ;
257- free ( array.ptr_2D ); array. ptr_2D = nullptr ;
258- free ( array.ptr_1D ); array. ptr_1D = nullptr ;
257+ delete[] array.ptr_2D ;
258+ delete[] array.ptr_1D ;
259259 }
260260
261261 template <typename T>
262262 Array_Pool<T>::~Array_Pool ()
263263 {
264- free ( ptr_2D) ;
265- free ( ptr_1D) ;
264+ delete[] ptr_2D;
265+ delete[] ptr_1D;
266266 }
267267}
268268
You can’t perform that action at this time.
0 commit comments