Commit 74fb6ece authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Improve destructor

parent 8fd7ca3c
...@@ -17,4 +17,7 @@ mark_as_advanced(BLC_CORE_INCLUDE_DIR BLC_CORE_LIBRARY ) ...@@ -17,4 +17,7 @@ mark_as_advanced(BLC_CORE_INCLUDE_DIR BLC_CORE_LIBRARY )
set(BL_DEFINITIONS -pthread -Wno-multichar ${BL_DEFINITIONS}) set(BL_DEFINITIONS -pthread -Wno-multichar ${BL_DEFINITIONS})
set(BL_INCLUDE_DIRS ${BLC_CORE_INCLUDE_DIR} ${BL_INCLUDE_DIRS} ) set(BL_INCLUDE_DIRS ${BLC_CORE_INCLUDE_DIR} ${BL_INCLUDE_DIRS} )
set(BL_LIBRARIES ${BLC_CORE_LIBRARY} -pthread ${BL_LIBRARIES}) set(BL_LIBRARIES ${BLC_CORE_LIBRARY} ${BL_LIBRARIES})
if (UNIX AND NOT APPLE) #On MacOSX -pthread is included
set(BL_LIBRARIES -pthread ${BL_LIBRARIES})
endif()
...@@ -33,9 +33,8 @@ char *file_texts=NULL; ...@@ -33,9 +33,8 @@ char *file_texts=NULL;
blc_array::blc_array():dims(NULL), dims_nb(0){} blc_array::blc_array():dims(NULL), dims_nb(0){}
blc_array::~blc_array(){ blc_array::~blc_array(){
FREE(dims); if (dims) FREE(dims);
} }
...@@ -176,6 +175,9 @@ void blc_array::fscan_dims(FILE *file){ ...@@ -176,6 +175,9 @@ void blc_array::fscan_dims(FILE *file){
FSCANF(1, file, "%d", &length); FSCANF(1, file, "%d", &length);
dims=NULL; dims=NULL;
dims_nb=0; dims_nb=0;
if (dims) FREE(dims);
if (length != 0){ if (length != 0){
do{ do{
dim=APPEND_ALLOCATION(&dims, &dims_nb, blc_dim); dim=APPEND_ALLOCATION(&dims, &dims_nb, blc_dim);
...@@ -196,6 +198,7 @@ int blc_array::sscan_dims(char const *string){ ...@@ -196,6 +198,7 @@ int blc_array::sscan_dims(char const *string){
SSCANF(1, string, "%d%n", &length, &pos); SSCANF(1, string, "%d%n", &length, &pos);
total_pos=pos; total_pos=pos;
dims_nb=0; dims_nb=0;
if (dims) FREE(dims);
if (length != 0){ if (length != 0){
do{ do{
total_pos+=pos; total_pos+=pos;
......
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