Commit 6aadef17 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Free the data. Only if data is not NULL and size !=0; It is a way to not...

Free the data. Only if data is not NULL and size !=0; It is a way to not delete data we want to keep.
parent 73dcbdc3
......@@ -53,7 +53,7 @@ typedef struct blc_mem {
blc_mem();
/** Create and allocate memory of size size */
blc_mem(size_t size);
/// Free the data
/// Free the data. Only if data is not NULL and size !=0; It is a way to not delete data we want to keep.
~blc_mem();
/**really allocates the data of size previously set*/
void allocate();
......
......@@ -28,8 +28,11 @@ blc_mem::blc_mem(size_t size)
}
blc_mem::~blc_mem(){
if (data) FREE(data); //Problem if the memory is static or does not belong to the blc_mem.
size=0;
if ((data) && (size))
{
FREE(data);
size=0;
}
}
void blc_mem::allocate(){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment