Changeset 17982


Ignore:
Timestamp:
05/12/14 14:08:03 (11 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed memory leak and clean up extrusion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r17976 r17982  
    12171217void       Penta::InputExtrude(int enum_type){/*{{{*/
    12181218
    1219         int     i,num_inputs;
    1220         Penta  *penta       = NULL;
    1221         Input  *copy        = NULL;
    1222         Input **base_inputs = NULL;
    1223 
    12241219        /*Are we on the base, not on the surface?:*/
    12251220        if(!IsOnBase()) return;
    12261221
    12271222        /*Step1: Get and Extrude original input: */
    1228         num_inputs=1;
    1229         base_inputs=xNew<Input*>(num_inputs);
    1230         base_inputs[0]=(Input*)this->inputs->GetInput(enum_type);
    1231         for(i=0;i<num_inputs;i++){
    1232                 if(!base_inputs[i]) _error_("could not find input with enum " << EnumToStringx(enum_type));
    1233                 base_inputs[i]->Extrude();
    1234         }
     1223        Input* base_input=(Input*)this->inputs->GetInput(enum_type);
     1224        if(!base_input) _error_("could not find input with enum " << EnumToStringx(enum_type));
     1225        base_input->Extrude();
    12351226
    12361227        /*Stop if there is only one layer of element*/
    1237         if (this->IsOnSurface()) return;
     1228        if(this->IsOnSurface()) return;
    12381229
    12391230        /*Step 2: this input has been extruded for this element, now follow the upper element*/
    1240         penta=this;
     1231        Penta* penta=this;
    12411232        for(;;){
    12421233                /* get upper Penta*/
     
    12451236
    12461237                /*Add input of the basal element to penta->inputs*/
    1247                 for(i=0;i<num_inputs;i++){
    1248                         copy=(Input*)base_inputs[i]->copy();
    1249                         penta->inputs->AddInput((Input*)copy);
    1250                 }
     1238                Input* copy=(Input*)base_input->copy();
     1239                penta->inputs->AddInput((Input*)copy);
    12511240
    12521241                /*Stop if we have reached the surface*/
    1253                 if (penta->IsOnSurface()) break;
    1254         }
    1255 
    1256         /*clean-up and return*/
    1257         xDelete<Input*>(base_inputs);
     1242                if(penta->IsOnSurface()) break;
     1243        }
    12581244}
    12591245/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.