CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   delete pointer of scalar in OpenFOAM (https://www.cfd-online.com/Forums/main/225924-delete-pointer-scalar-openfoam.html)

mb.pejvak April 12, 2020 00:46

delete pointer of scalar in OpenFOAM
 
I created dynamic arrays of scalar in openfoam like this
Code:

int num = 10;
scalar myScalar = new scalar[num];


and then I want to delete the pointer of array like this
Code:

delete[] myScalar;

but it seems for scalar class, delete operator has not been defined. So my question is how I should delete pointer of array to prevent memory leak.

LuckyTran April 13, 2020 10:09

To call delete you normally would need to allocate it using something like:

Code:

scalar *myScalar = new scalar[num];

Or does that not fix the issue?


All times are GMT -4. The time now is 14:51.