Changeset 12451


Ignore:
Timestamp:
06/18/12 15:33:50 (13 years ago)
Author:
Mathieu Morlighem
Message:

minor bug fix with xDelete

Location:
issm/trunk-jpl/src/c
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp

    r12450 r12451  
    136136                               
    137137                                /*Free ressources:*/
    138                                 xDelete<int>(dakota_parameter);
     138                                xDelete<double>(dakota_parameter);
    139139                        }
    140140                }
     
    214214                xDelete<char*>(variabledescriptors);
    215215                xDelete<int>(part);
    216                 xDelete<int>(dpart);
     216                xDelete<double>(dpart);
    217217                xDelete<char>(qmuinname);
    218218                xDelete<char>(qmuerrname);
  • issm/trunk-jpl/src/c/objects/Params/DoubleMatArrayParam.cpp

    r12365 r12451  
    3636        M=in_M;
    3737        if(M){
    38                 array=(double**)xmalloc(M*sizeof(double*));
    39                 mdim_array=(int*)xmalloc(M*sizeof(int));
    40                 ndim_array=(int*)xmalloc(M*sizeof(int));
     38                array=xNew<double*>(M);
     39                mdim_array=xNew<int>(M);
     40                ndim_array=xNew<int>(M);
    4141
    4242                for(i=0;i<M;i++){
     
    4848
    4949                        if(m*n){
    50                                 matrix=(double*)xmalloc(m*n*sizeof(double));
     50                                matrix=xNew<double>(m*n);
    5151                                memcpy(matrix,in_array[i],m*n*sizeof(double));
    5252                        }
     
    7070        double* matrix=NULL;
    7171
    72         xfree((void**)&mdim_array);
    73         xfree((void**)&ndim_array);
     72        xDelete<int>(mdim_array);
     73        xDelete<int>(ndim_array);
    7474
    7575        for(i=0;i<M;i++){
    7676                matrix=array[i];
    77                 xfree((void**)&matrix);
    78         }
    79        
    80         xfree((void**)&array);
     77                xDelete<double>(matrix);
     78        }
     79       
     80        xDelete<double*>(array);
    8181        return;
    8282}
     
    159159        out_M=this->M;
    160160        if(out_M){
    161                 out_array=(double**)xmalloc(M*sizeof(double*));
    162                 out_mdim_array=(int*)xmalloc(M*sizeof(int));
    163                 out_ndim_array=(int*)xmalloc(M*sizeof(int));
     161                out_array=xNew<double*>(M);
     162                out_mdim_array=xNew<int>(M);
     163                out_ndim_array=xNew<int>(M);
    164164
    165165                memcpy(out_mdim_array,this->mdim_array,M*sizeof(int));
     
    172172
    173173                        if(m*n){
    174                                 out_matrix=(double*)xmalloc(m*n*sizeof(double));
     174                                out_matrix=xNew<double>(m*n);
    175175                                memcpy(out_matrix,matrix,m*n*sizeof(double));
    176176                        }
     
    209209
    210210        /*avoid leak: */
    211         xfree((void**)&mdim_array);
    212         xfree((void**)&ndim_array);
     211        xDelete<int>(mdim_array);
     212        xDelete<int>(ndim_array);
    213213        for(i=0;i<M;i++){
    214214                matrix=array[i];
    215                 xfree((void**)&matrix);
    216         }
    217         xfree((void**)&array);
     215                xDelete<double>(matrix);
     216        }
     217        xDelete<double*>(array);
    218218
    219219        /*copy data: */
    220220        this->M=in_M;
    221         this->array=(double**)xmalloc(M*sizeof(double*));
    222         this->mdim_array=(int*)xmalloc(M*sizeof(int));
    223         this->ndim_array=(int*)xmalloc(M*sizeof(int));
     221        this->array=xNew<double*>(M);
     222        this->mdim_array=xNew<int>(M);
     223        this->ndim_array=xNew<int>(M);
    224224       
    225225        memcpy(this->mdim_array,in_mdim_array,M*sizeof(double));
     
    231231                n=in_ndim_array[i];
    232232
    233                 matrix=(double*)xmalloc(m*n*sizeof(double));
     233                matrix=xNew<double>(m*n);
    234234                memcpy(matrix,in_matrix,m*n*sizeof(double));
    235235
  • issm/trunk-jpl/src/c/objects/Params/DoubleMatParam.cpp

    r12365 r12451  
    3333        N=in_N;
    3434
    35         value=(double*)xmalloc(M*N*sizeof(double));
     35        value=xNew<double>(M*N);
    3636        memcpy(value,in_value,M*N*sizeof(double));
    3737}
     
    9898        double* output=NULL;
    9999
    100         output=(double*)xmalloc((int)(M*N*sizeof(double)));
     100        output=xNew<double>(M*N);
    101101        memcpy(output,value,M*N*sizeof(double));
    102102
     
    123123        xfree((void**)&this->value);
    124124
    125         this->value=(double*)xmalloc(in_M*in_N*sizeof(double));
     125        this->value=xNew<double>(in_M*in_N);
    126126        memcpy(this->value,doublearray,in_M*in_N*sizeof(double));
    127127
  • issm/trunk-jpl/src/c/objects/Params/IntMatParam.cpp

    r12365 r12451  
    3333        N=in_N;
    3434
    35         value=(int*)xmalloc(M*N*sizeof(int));
     35        value=xNew<int>(M*N);
    3636        memcpy(value,in_value,M*N*sizeof(int));
    3737}
     
    3939/*FUNCTION IntMatParam::~IntMatParam(){{{*/
    4040IntMatParam::~IntMatParam(){
    41         xfree((void**)&value);
     41        xDelete<int>(value);
    4242        return;
    4343}
     
    9898        int* output=NULL;
    9999
    100         output=(int*)xmalloc((int)(M*N*sizeof(int)));
     100        output=xNew<int>(M*N);
    101101        memcpy(output,value,M*N*sizeof(int));
    102102
     
    116116
    117117        /*avoid leak: */
    118         xfree((void**)&this->value);
     118        xDelete<int>(this->value);
    119119
    120         this->value=(int*)xmalloc(in_M*in_N*sizeof(int));
     120        this->value=xNew<int>(in_M*in_N);
    121121        memcpy(this->value,intarray,in_M*in_N*sizeof(int));
    122122
  • issm/trunk-jpl/src/c/objects/Params/IntVecParam.cpp

    r12365 r12451  
    3333
    3434        if(M){
    35                 values=(int*)xmalloc(M*sizeof(int));
     35                values=xNew<int>(M);
    3636                memcpy(values,in_values,M*sizeof(int));
    3737        }
     
    4646
    4747        if(M){
    48                 values=(int*)xmalloc(M*sizeof(int));
     48                values=xNew<int>(M);
    4949                for(int i=0;i<in_M;i++) values[i]=(int)in_values[i];
    5050        }
     
    5454/*FUNCTION IntVecParam::~IntVecParam(){{{*/
    5555IntVecParam::~IntVecParam(){
    56         xfree((void**)&values);
     56        xDelete<int>(values);
    5757        return;
    5858}
     
    112112
    113113        if(M){
    114                 output=(int*)xmalloc(M*sizeof(int));
     114                output=xNew<int>(M);
    115115                memcpy(output,values,M*sizeof(int));
    116116        }
     
    130130
    131131        /*avoid leak: */
    132         xfree((void**)&this->values);
     132        xDelete<int>(this->values);
    133133
    134134        if(in_M){
    135                 this->values=(int*)xmalloc(in_M*sizeof(int));
     135                this->values=xNew<int>(in_M);
    136136                memcpy(this->values,intarray,in_M*sizeof(int));
    137137        }
  • issm/trunk-jpl/src/c/objects/Params/StringArrayParam.cpp

    r12365 r12451  
    3636
    3737        if(numstrings){
    38                 value=(char**)xmalloc(numstrings*sizeof(char*));
     38                value=xNew<char*>(numstrings);
    3939                for(i=0;i<numstrings;i++){
    4040                        char* string=NULL;
    4141                        size=strlen(in_values[i])+1;
    42                         string=(char*)xmalloc(size*sizeof(char));
     42                        string=xNew<char>(size);
    4343                        memcpy(string,in_values[i],size*sizeof(char));
    4444                        value[i]=string;
     
    5757        for(i=0;i<this->numstrings;i++){
    5858                string=value[i];
    59                 xfree((void**)&string);
     59                xDelete<char>(string);
    6060        }
    61         xfree((void**)&value);
     61        xDelete<char*>(value);
    6262}
    6363/*}}}*/
     
    120120        M=this->numstrings;
    121121        if(this->numstrings){
    122                 outstrings=(char**)xmalloc(this->numstrings*sizeof(char*));
     122                outstrings=xNew<char*>(this->numstrings);
    123123
    124124                for(i=0;i<this->numstrings;i++){
     
    126126                        stringsize=strlen(string)+1;
    127127
    128                         string2=(char*)xmalloc(stringsize*sizeof(char));
     128                        string2=xNew<char>(stringsize);
    129129                        memcpy(string2,string,stringsize*sizeof(char));
    130130
     
    155155        for(i=0;i<this->numstrings;i++){
    156156                string=this->value[i];
    157                 xfree((void**)&string);
     157                xDelete<char>(string);
    158158        }
    159         xfree((void**)&this->value);
     159        xDelete<char*>(this->value);
    160160
    161161        /*copy: */
    162162        this->numstrings=M;
    163         this->value=(char**)xmalloc(this->numstrings*sizeof(char*));
     163        this->value=xNew<char*>(this->numstrings);
    164164        for(i=0;i<this->numstrings;i++){
    165165                string=stringarray[i];
    166166                stringsize=strlen(string)+1;
    167167
    168                 string2=(char*)xmalloc(stringsize*sizeof(char));
     168                string2=xNew<char>(stringsize);
    169169                memcpy(string2,string,stringsize*sizeof(char));
    170170
  • issm/trunk-jpl/src/c/objects/Params/StringParam.cpp

    r12365 r12451  
    3030
    3131        enum_type=in_enum_type;
    32         value=(char*)xmalloc((strlen(in_value)+1)*sizeof(char));
     32        value=xNew<char>(strlen(in_value)+1);
    3333        memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char));
    3434
     
    3838/*FUNCTION StringParam::~StringParam(){{{*/
    3939StringParam::~StringParam(){
    40         xfree((void**)&value);
     40        xDelete<char>(value);
    4141}
    4242/*}}}*/
     
    8888        stringsize=strlen(this->value)+1;
    8989
    90         outstring=(char*)xmalloc(stringsize*sizeof(char));
     90        outstring=xNew<char>(stringsize);
    9191        memcpy(outstring,this->value,stringsize*sizeof(char));
    9292
     
    106106       
    107107        /*avoid leak: */
    108         xfree((void**)&this->value);
     108        xDelete<char>(this->value);
    109109
    110110        /*copy: */
    111111        stringsize=strlen(string)+1;
    112         this->value=(char*)xmalloc(stringsize*sizeof(char));
     112        this->value=xNew<char>(stringsize);
    113113        memcpy(this->value,string,stringsize*sizeof(char));
    114114
Note: See TracChangeset for help on using the changeset viewer.