Proper releasing dynamic allocated memory
Hi,
I have allocated memory for 3-dimensinonal array in this way:
1 2 3 4 5 6 7 8 9 10
|
Matrix ***channel_coefficient;
channel_coefficient=new Matrix**[drop_number];
for(int i=0;i<drop_number;i++)
{
channel_coefficient[i]=new Matrix*[N];
for(int j=0;j<N;j++)
{
channel_coefficient[i][j]=new Matrix[sample_number];
}
}
|
where Matrix is matrix data type
My question is, if following code is valid for releasing memory for above array?
1 2 3 4 5 6 7 8 9
|
for(int i=0;i<drop_number;i++)
{
for(int j=0;j<N;j++)
{
delete[] channel_coefficient[i][j];
}
delete[] channel_coefficient[i];
}
delete [] channel_coefficient;
|
I would be grateful for any comments.
Yes.
Thanks for help.
Topic archived. No new replies allowed.