Index: ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp =================================================================== --- ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp (revision 16498) +++ ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp (revision 16499) @@ -21,12 +21,15 @@ definition=dynamic_cast(output_definitions->GetObjectByOffset(i)); - if (strcmp(definition->Name(),output_string)==0){ + char* name = definition->Name(); + if (strcmp(name,output_string)==0){ /*This is the object that we have been chasing for. compute the response and return: */ return_value=definition->Response(femmodel); delete output_definitions; + xDelete(name); return return_value; } + xDelete(name); } /*If we are here, did not find the definition for this response, not good!: */ _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!"); Index: ../trunk-jpl/src/c/classes/IoModel.cpp =================================================================== --- ../trunk-jpl/src/c/classes/IoModel.cpp (revision 16498) +++ ../trunk-jpl/src/c/classes/IoModel.cpp (revision 16499) @@ -1087,14 +1087,14 @@ int* codes=NULL; /*output: */ - int numstrings=0; - char** strings=NULL; + int numstrings = 0; + char **strings = NULL; /*intermediary: */ - char* string=NULL; - int string_size; - int* code=NULL; - fpos_t* file_positions=NULL; + char *string = NULL; + int string_size; + int *code = NULL; + fpos_t *file_positions = NULL; /*recover my_rank:*/ my_rank=IssmComm::GetRank(); @@ -1103,12 +1103,10 @@ file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); if(num_instances){ - strings=xNew(num_instances); for(i=0;i(codes); @@ -1152,24 +1149,22 @@ int i; int num_instances; - int my_rank; - fpos_t* file_positions=NULL; /*output: */ - IssmDouble** matrices=NULL; - int* mdims=NULL; - int* ndims=NULL; + IssmDouble **matrices = NULL; + int *mdims = NULL; + int *ndims = NULL; /*intermediary: */ - int M, N; + int M, N; IssmPDouble *pmatrix = NULL; - IssmDouble *matrix = NULL; - int* codes=NULL; - int code; + IssmDouble *matrix = NULL; + int *codes = NULL; + int code; /*recover my_rank:*/ - my_rank=IssmComm::GetRank(); + int my_rank=IssmComm::GetRank(); /*Get file pointers to beginning of the data (multiple instances of it): */ file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); @@ -1181,7 +1176,7 @@ mdims=xNew(num_instances); ndims=xNew(num_instances); - for(i=0;iindependents); - if (this->independents[data_enum]){ + if(this->independents[data_enum]){ /*this data has already been checked out! So cancel all that we've done here, and return * the data[data_enum] directly: */ matrix=this->data[data_enum]; @@ -1239,8 +1234,18 @@ /*Assign output pointers: */ *pmatrices=matrices; - if(pmdims)*pmdims=mdims; - if(pndims)*pndims=ndims; + if(pmdims){ + *pmdims=mdims; + } + else{ + xDelete(mdims); + } + if(pndims){ + *pndims=ndims; + } + else{ + xDelete(ndims); + } *pnumrecords=num_instances; } /*}}}*/ @@ -1447,20 +1452,19 @@ /*FUNCTION IoModel::SetFilePointersToData{{{*/ fpos_t* IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){ - int my_rank; - int found = 0; - int record_enum; - int record_length; - int record_code; //1 to 7 number - int vector_type; //1 to 7 number - int* vector_types = NULL; - int* codes= NULL; - int num_instances = 0; - int counter; - fpos_t* file_positions=NULL; + int found = 0; + int record_enum; + int record_length; + int record_code; //1 to 7 number + int vector_type; //1 to 7 number + int *vector_types = NULL; + int *codes = NULL; + int num_instances = 0; + int counter; + fpos_t *file_positions = NULL; /*recover my_rank:*/ - my_rank=IssmComm::GetRank(); + int my_rank=IssmComm::GetRank(); /*Go find in the binary file, the data we want to fetch and count the number of * instances it appears: */ @@ -1488,10 +1492,9 @@ /*Ok, initialize the number of file handles we are going to return: */ if(num_instances){ file_positions = xNew(num_instances); - codes = xNew(num_instances); - vector_types = xNew(num_instances); + codes = xNew(num_instances); + vector_types = xNew(num_instances); } - /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information * as we find it: */ @@ -1515,8 +1518,8 @@ if(5<=record_code && record_code<=7){ if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type"); } - codes[counter]=record_code; - vector_types[counter]=vector_type; + codes[counter] = record_code; + vector_types[counter] = vector_type; fgetpos(fid,file_positions+counter); /*backup and skip over the record, as we have more work to do: */ @@ -1539,9 +1542,14 @@ ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm()); /*Assign output pointers:*/ - *pcodes=codes; - *pnum_instances=num_instances; - if(pvector_types)*pvector_types=vector_types; + *pcodes = codes; + *pnum_instances = num_instances; + if(pvector_types){ + *pvector_types=vector_types; + } + else{ + xDelete(vector_types); + } return file_positions; } /*}}}*/ Index: ../trunk-jpl/src/c/classes/Massfluxatgate.h =================================================================== --- ../trunk-jpl/src/c/classes/Massfluxatgate.h (revision 16498) +++ ../trunk-jpl/src/c/classes/Massfluxatgate.h (revision 16499) @@ -126,10 +126,9 @@ /*}}}*/ /*Definition virtual function resolutoin: */ /*FUNCTION char* Name() {{{*/ - char* Name(){ - char* name2=NULL; + char* Name(){ - name2=xNew(strlen(this->name)+1); + char* name2=xNew(strlen(this->name)+1); xMemCpy(name2,this->name,strlen(this->name)+1); return name2;