Commit 7382710e authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Add a function .free to the blc_mem

parent 15eb9a46
......@@ -80,6 +80,8 @@ typedef struct blc_mem {
void replace(char const *new_data, size_t size);
/** Reset all the value to 'value'. */
void reset(int value=0);
void free();
#endif
}blc_mem;
......
......@@ -75,8 +75,8 @@ void blc_array::def_array(uint32_t type, uint32_t format, char const *dims_strin
}
void blc_array::destroy(){
FREE(data);
FREE(dims);
free();
::free(dims);
}
void blc_array::add_dim(int length, int step){
......@@ -98,7 +98,7 @@ void blc_array::set_dims(int dims_nb, int length, ...){
blc_dim *dim;
va_list args;
FREE(dims);
::free(dims);
this->dims_nb=dims_nb;
dims=MANY_ALLOCATIONS(dims_nb, blc_dim);
......
......@@ -41,7 +41,7 @@ void blc_mem::allocate(size_t new_size)
{
if (new_size != size || data == NULL) // Changement de taille ou l'allocation n'a encore jamais été faite
{
free(data);
::free(data);
data = MANY_ALLOCATIONS(new_size, char);
size = new_size;
}
......@@ -50,7 +50,7 @@ void blc_mem::allocate(size_t new_size)
void blc_mem::allocate_min(size_t new_size)
{
if (new_size > size){
free(data);
::free(data);
data = MANY_ALLOCATIONS(new_size, char);
size = new_size;
}
......@@ -85,6 +85,12 @@ void blc_mem::reset(int value){
memset(data, value, size);
}
void blc_mem::free(){
::free(data); //:: not calling itself but system call
data=NULL;
size=0;
}
/* C wrapper */
extern "C" {
void blc_mem_allocate(blc_mem *mem, size_t size)
......
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