Changeset 12455


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

changing xmalloc to xNew and xfree to xDelete

Location:
issm/trunk-jpl/src/c/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/objects/Gauss/GaussPenta.cpp

    r12365 r12455  
    4747        /*Allocate GaussPenta fields*/
    4848        numgauss=numgauss_horiz*numgauss_vert;
    49         coords1=(double*)xmalloc(numgauss*sizeof(double));
    50         coords2=(double*)xmalloc(numgauss*sizeof(double));
    51         coords3=(double*)xmalloc(numgauss*sizeof(double));
    52         coords4=(double*)xmalloc(numgauss*sizeof(double));
    53         weights=(double*)xmalloc(numgauss*sizeof(double));
     49        coords1=xNew<double>(numgauss);
     50        coords2=xNew<double>(numgauss);
     51        coords3=xNew<double>(numgauss);
     52        coords4=xNew<double>(numgauss);
     53        weights=xNew<double>(numgauss);
    5454
    5555        /*Combine Horizontal and vertical points*/
     
    7272
    7373        /*Clean up*/
    74         xfree((void**)&coords1_horiz);
    75         xfree((void**)&coords2_horiz);
    76         xfree((void**)&coords3_horiz);
    77         xfree((void**)&coords_vert);
    78         xfree((void**)&weights_horiz);
    79         xfree((void**)&weights_vert);
     74        xDelete<double>(coords1_horiz);
     75        xDelete<double>(coords2_horiz);
     76        xDelete<double>(coords3_horiz);
     77        xDelete<double>(coords_vert);
     78        xDelete<double>(weights_horiz);
     79        xDelete<double>(weights_vert);
    8080}
    8181/*}}}*/
     
    9393
    9494        /*Allocate GaussPenta fields*/
    95         coords1=(double*)xmalloc(numgauss*sizeof(double));
    96         coords2=(double*)xmalloc(numgauss*sizeof(double));
    97         coords3=(double*)xmalloc(numgauss*sizeof(double));
    98         coords4=(double*)xmalloc(numgauss*sizeof(double));
    99         weights=(double*)xmalloc(numgauss*sizeof(double));
     95        coords1=xNew<double>(numgauss);
     96        coords2=xNew<double>(numgauss);
     97        coords3=xNew<double>(numgauss);
     98        coords4=xNew<double>(numgauss);
     99        weights=xNew<double>(numgauss);
    100100
    101101        if(index1==0 && index2==3){
     
    132132
    133133        /*clean up*/
    134         xfree((void**)&seg_coords);
    135         xfree((void**)&seg_weights);
     134        xDelete<double>(seg_coords);
     135        xDelete<double>(seg_weights);
    136136
    137137}
     
    147147
    148148                /*compute z coordinate*/
    149                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     149                coords4=xNew<double>(numgauss);
    150150                for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
    151151        }
     
    157157
    158158                /*compute z coordinate*/
    159                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     159                coords4=xNew<double>(numgauss);
    160160                for(int i=0;i<numgauss;i++) coords4[i]=1.0;
    161161        }
     
    182182        /*Allocate GaussPenta fields*/
    183183        numgauss=order_horiz*order_vert;
    184         coords1=(double*)xmalloc(numgauss*sizeof(double));
    185         coords2=(double*)xmalloc(numgauss*sizeof(double));
    186         coords3=(double*)xmalloc(numgauss*sizeof(double));
    187         coords4=(double*)xmalloc(numgauss*sizeof(double));
    188         weights=(double*)xmalloc(numgauss*sizeof(double));
     184        coords1=xNew<double>(numgauss);
     185        coords2=xNew<double>(numgauss);
     186        coords3=xNew<double>(numgauss);
     187        coords4=xNew<double>(numgauss);
     188        weights=xNew<double>(numgauss);
    189189
    190190        /*Quads: get the gauss points using the product of two line rules  */
     
    227227
    228228        /*clean-up*/
    229         xfree((void**)&seg_horiz_coords);
    230         xfree((void**)&seg_horiz_weights);
    231         xfree((void**)&seg_vert_coords);
    232         xfree((void**)&seg_vert_weights);
     229        xDelete<double>(seg_horiz_coords);
     230        xDelete<double>(seg_horiz_weights);
     231        xDelete<double>(seg_vert_coords);
     232        xDelete<double>(seg_vert_weights);
    233233}
    234234/*}}}*/
    235235/*FUNCTION GaussPenta::~GaussPenta(){{{*/
    236236GaussPenta::~GaussPenta(){
    237         xfree((void**)&weights);
    238         xfree((void**)&coords1);
    239         xfree((void**)&coords2);
    240         xfree((void**)&coords3);
    241         xfree((void**)&coords4);
     237        xDelete<double>(weights);
     238        xDelete<double>(coords1);
     239        xDelete<double>(coords2);
     240        xDelete<double>(coords3);
     241        xDelete<double>(coords4);
    242242}
    243243/*}}}*/
     
    357357        if(index1==0 && index2==1 && index3==2){
    358358                GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
    359                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     359                coords4=xNew<double>(numgauss);
    360360                for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
    361361        }
  • issm/trunk-jpl/src/c/objects/Gauss/GaussTria.cpp

    r12424 r12455  
    9191
    9292        /*clean up*/
    93         xfree((void**)&seg_coords);
    94         xfree((void**)&seg_weights);
     93        xDelete<double>(seg_coords);
     94        xDelete<double>(seg_weights);
    9595}
    9696/*}}}*/
  • issm/trunk-jpl/src/c/objects/Inputs/TransientInput.cpp

    r12426 r12455  
    4646/*FUNCTION TransientInput::~TransientInput{{{*/
    4747TransientInput::~TransientInput(){
    48         xfree((void**)&this->timesteps);
     48        xDelete<double>(this->timesteps);
    4949        this->timesteps=NULL;
    5050        this->numtimesteps=0;
     
    100100        output->enum_type=this->enum_type;
    101101        output->numtimesteps=this->numtimesteps;
    102         output->timesteps=(IssmPDouble*)xmalloc(this->numtimesteps*sizeof(IssmPDouble));
     102        output->timesteps=xNew<IssmPDouble>(this->numtimesteps);
    103103   memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmPDouble));
    104104        output->inputs=(Inputs*)this->inputs->Copy();
     
    128128        outinput->enum_type=this->enum_type;
    129129        outinput->numtimesteps=this->numtimesteps;
    130         outinput->timesteps=(IssmPDouble*)xmalloc(this->numtimesteps*sizeof(IssmPDouble));
     130        outinput->timesteps=xNew<IssmPDouble>(this->numtimesteps);
    131131        memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmPDouble));
    132132        outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
     
    237237
    238238        if (this->numtimesteps > 0){
    239                 old_timesteps=(IssmPDouble*)xmalloc(this->numtimesteps*sizeof(IssmPDouble));
     239                old_timesteps=xNew<IssmPDouble>(this->numtimesteps);
    240240                memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(IssmPDouble));
    241                 xfree((void**)&this->timesteps);
     241                xDelete<double>(this->timesteps);
    242242        }
    243243
    244244        this->numtimesteps=this->numtimesteps+1;
    245         this->timesteps=(IssmPDouble*)xmalloc(this->numtimesteps*sizeof(IssmPDouble));
     245        this->timesteps=xNew<IssmPDouble>(this->numtimesteps);
    246246
    247247        if (this->numtimesteps > 1){
    248248                memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(IssmPDouble));
    249                 xfree((void**)&old_timesteps);
     249                xDelete<double>(old_timesteps);
    250250        }
    251251
  • issm/trunk-jpl/src/c/objects/Kriging/Quadtree.cpp

    r12365 r12455  
    496496
    497497        /*Allocate indices (maximum by default*/
    498         if(this->NbObs) indices = (int*)xmalloc(this->NbObs*sizeof(int));
     498        if(this->NbObs) indices = xNew<int>(this->NbObs);
    499499        nobs = 0;
    500500
  • issm/trunk-jpl/src/c/objects/Loads/Friction.cpp

    r12424 r12455  
    3333        this->analysis_type=in_analysis_type;
    3434        this->inputs=inputs_in;
    35         this->element_type=(char*)xmalloc((strlen(element_type_in)+1)*sizeof(char));
     35        this->element_type=xNew<char>(strlen(element_type_in)+1);
    3636        memcpy(this->element_type,element_type_in,(strlen(element_type_in)+1)*sizeof(char));
    3737
     
    4141/*FUNCTION Friction::~Friction() {{{*/
    4242Friction::~Friction(){
    43         xfree((void**)&element_type);
     43        xDelete<char>(element_type);
    4444}
    4545/*}}}*/
  • issm/trunk-jpl/src/c/objects/Loads/Icefront.cpp

    r12365 r12455  
    691691
    692692        /*Allocate: */
    693         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     693        doflist=xNew<int>(numberofdofs);
    694694
    695695        /*Populate: */
Note: See TracChangeset for help on using the changeset viewer.