Changeset 12458


Ignore:
Timestamp:
06/18/12 16:25:19 (13 years ago)
Author:
Mathieu Morlighem
Message:

changing xmalloc to xNew and xfree to xDelete

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

Legend:

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

    r12406 r12458  
    100100
    101101        //deal with PentaRef mother class
    102         penta->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
     102        penta->element_type_list=xNew<int>(this->numanalyses);
    103103        for(i=0;i<this->numanalyses;i++) penta->element_type_list[i]=this->element_type_list[i];
    104104
     
    130130
    131131        /*recover objects: */
    132         penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     132        penta->nodes=xNew<Node*>(6); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    133133        for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
    134134        penta->matice=(Matice*)penta->hmatice->delivers();
     
    730730
    731731        /*Allocate: */
    732         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     732        doflist=xNew<int>(numberofdofs);
    733733
    734734        /*Populate: */
     
    11471147        Input** old_inputs=NULL;
    11481148
    1149         new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
    1150         old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
     1149        new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
     1150        old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
    11511151
    11521152        for(i=0;i<num_enums/2;i++){
     
    11641164
    11651165        /*clean up*/
    1166         xfree((void**)&new_inputs);
    1167         xfree((void**)&old_inputs);
     1166        xDelete<Input*>(new_inputs);
     1167        xDelete<Input*>(old_inputs);
    11681168
    11691169        /*Return output*/
     
    13991399        if (object_type==ElementEnum){
    14001400                num_inputs=1;
    1401                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1401                base_inputs=xNew<Input*>(num_inputs);
    14021402                base_inputs[0]=(Input*)this->inputs->GetInput(enum_type);
    14031403        }
    14041404        else if (object_type==MaterialsEnum){
    14051405                num_inputs=1;
    1406                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1406                base_inputs=xNew<Input*>(num_inputs);
    14071407                base_inputs[0]=(Input*)matice->inputs->GetInput(enum_type);
    14081408        }
    14091409        else if (object_type==NodeEnum){
    14101410                num_inputs=3; //only the three upper nodes
    1411                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1411                base_inputs=xNew<Input*>(num_inputs);
    14121412                for(i=0;i<num_inputs;i++){
    14131413                        base_inputs[i]=(Input*)this->nodes[i]->inputs->GetInput(enum_type);
     
    14541454
    14551455        /*clean-up and return*/
    1456         xfree((void**)&base_inputs);
     1456        xDelete<Input*>(base_inputs);
    14571457}
    14581458/*}}}*/
     
    17951795       
    17961796        /*Free ressources:*/
    1797         xfree((void**)&doflist);
     1797        xDelete<int>(doflist);
    17981798}
    17991799/*}}}*/
     
    18191819       
    18201820        /*Free ressources:*/
    1821         xfree((void**)&doflist);
     1821        xDelete<int>(doflist);
    18221822}
    18231823/*}}}*/
     
    18591859       
    18601860        /*Free ressources:*/
    1861         xfree((void**)&doflist);
     1861        xDelete<int>(doflist);
    18621862}
    18631863/*}}}*/
     
    20312031
    20322032                /*Allocate output*/
    2033                 resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    2034                 resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
    2035                 resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
    2036                 resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
     2033                resultsenums=xNew<int>(numberofresults);
     2034                resultssizes=xNew<int>(numberofresults);
     2035                resultstimes=xNew<double>(numberofresults);
     2036                resultssteps=xNew<int>(numberofresults);
    20372037
    20382038                /*populate enums*/
     
    42694269        /*Free ressources:*/
    42704270        delete gauss;
    4271         xfree((void**)&doflist);
     4271        xDelete<int>(doflist);
    42724272}
    42734273/*}}}*/
     
    43004300        /*Free ressources:*/
    43014301        delete gauss;
    4302         xfree((void**)&doflist);
     4302        xDelete<int>(doflist);
    43034303}
    43044304/*}}}*/
     
    43714371
    43724372        /*Free ressources:*/
    4373         xfree((void**)&doflist);
     4373        xDelete<int>(doflist);
    43744374}
    43754375/*}}}*/
     
    44494449
    44504450        /*Free ressources:*/
    4451         xfree((void**)&doflist);
     4451        xDelete<int>(doflist);
    44524452}
    44534453/*}}}*/
     
    48684868                        _error_("response %s not supported yet",EnumToStringx(responses[resp]));
    48694869        }
    4870         xfree((void**)&responses);
     4870        xDelete<int>(responses);
    48714871}
    48724872/*}}}*/
     
    51335133        /*Clean up and return*/
    51345134cleanup_and_return:
    5135         xfree((void**)&control_type);
     5135        xDelete<int>(control_type);
    51365136}
    51375137/*}}}*/
     
    51765176
    51775177        /*Free ressources:*/
    5178         xfree((void**)&doflist);
     5178        xDelete<int>(doflist);
    51795179}
    51805180/*}}}*/
     
    52115211
    52125212        /*Free ressources:*/
    5213         xfree((void**)&doflist);
     5213        xDelete<int>(doflist);
    52145214}
    52155215/*}}}*/
     
    79407940        /*Free ressources:*/
    79417941        delete gauss;
    7942         xfree((void**)&doflist);
     7942        xDelete<int>(doflist);
    79437943}
    79447944/*}}}*/
     
    79767976        /*Free ressources:*/
    79777977        delete gauss;
    7978         xfree((void**)&doflist);
     7978        xDelete<int>(doflist);
    79797979}
    79807980/*}}}*/
     
    80098009        /*Free ressources:*/
    80108010        delete gauss;
    8011         xfree((void**)&doflist);
     8011        xDelete<int>(doflist);
    80128012}
    80138013/*}}}*/
     
    80548054        /*Free ressources:*/
    80558055        delete gauss;
    8056         xfree((void**)&doflist);
     8056        xDelete<int>(doflist);
    80578057}
    80588058/*}}}*/
     
    81718171       
    81728172        /*Free ressources:*/
    8173         xfree((void**)&doflist);
     8173        xDelete<int>(doflist);
    81748174}
    81758175/*}}}*/
     
    82548254
    82558255        /*Free ressources:*/
    8256         xfree((void**)&doflistp);
    8257         xfree((void**)&doflistm);
     8256        xDelete<int>(doflistp);
     8257        xDelete<int>(doflistm);
    82588258}
    82598259/*}}}*/
     
    83548354
    83558355        /*Free ressources:*/
    8356         xfree((void**)&doflistm);
    8357         xfree((void**)&doflists);
     8356        xDelete<int>(doflistm);
     8357        xDelete<int>(doflists);
    83588358}
    83598359/*}}}*/
     
    84298429
    84308430        /*Free ressources:*/
    8431         xfree((void**)&doflist);
     8431        xDelete<int>(doflist);
    84328432}
    84338433/*}}}*/
     
    85228522
    85238523        /*Free ressources:*/
    8524         xfree((void**)&doflistp);
    8525         xfree((void**)&doflists);
     8524        xDelete<int>(doflistp);
     8525        xDelete<int>(doflists);
    85268526}
    85278527/*}}}*/
     
    85868586
    85878587        /*Free ressources:*/
    8588         xfree((void**)&doflist);
     8588        xDelete<int>(doflist);
    85898589}
    85908590/*}}}*/
     
    86908690
    86918691        /*Free ressources:*/
    8692         xfree((void**)&doflist);
     8692        xDelete<int>(doflist);
    86938693}
    86948694/*}}}*/
     
    87518751
    87528752        /*Free ressources:*/
    8753         xfree((void**)&doflist);
     8753        xDelete<int>(doflist);
    87548754}
    87558755/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/PentaRef.cpp

    r12365 r12458  
    3535
    3636        /*Only allocate pointer*/
    37         element_type_list=(int*)xmalloc(nummodels*sizeof(int));
     37        element_type_list=xNew<int>(nummodels);
    3838
    3939}
     
    4141/*FUNCTION PentaRef::~PentaRef(){{{*/
    4242PentaRef::~PentaRef(){
    43         xfree((void**)&element_type_list);
     43        xDelete<int>(element_type_list);
    4444}
    4545/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/Tria.cpp

    r12406 r12458  
    8282
    8383        //deal with TriaRef mother class
    84         tria->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
     84        tria->element_type_list=xNew<int>(this->numanalyses);
    8585        for(i=0;i<this->numanalyses;i++) tria->element_type_list[i]=this->element_type_list[i];
    8686
     
    111111
    112112        /*recover objects: */
    113         tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     113        tria->nodes=xNew<Node*>(3); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    114114        for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
    115115        tria->matice=(Matice*)tria->hmatice->delivers();
     
    974974        /*First, figure out size of doflist and create it: */
    975975        for(i=0;i<3;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
    976         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     976        doflist=xNew<int>(numberofdofs);
    977977
    978978        /*Populate: */
     
    12461246        Input** old_inputs=NULL;
    12471247
    1248         new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
    1249         old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
     1248        new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
     1249        old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
    12501250
    12511251        for(i=0;i<num_enums/2;i++){
     
    12631263
    12641264        /*clean up and return*/
    1265         xfree((void**)&new_inputs);
    1266         xfree((void**)&old_inputs);
     1265        xDelete<Input*>(new_inputs);
     1266        xDelete<Input*>(old_inputs);
    12671267        return converged;
    12681268}
     
    15301530
    15311531        /*Free ressources:*/
    1532         xfree((void**)&doflist);
     1532        xDelete<int>(doflist);
    15331533}
    15341534/*}}}*/
     
    15971597
    15981598        /*Free ressources:*/
    1599         xfree((void**)&doflist);
     1599        xDelete<int>(doflist);
    16001600}
    16011601/*}}}*/
     
    18621862
    18631863                /*Allocate output*/
    1864                 resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    1865                 resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
    1866                 resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
    1867                 resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
     1864                resultsenums=xNew<int>(numberofresults);
     1865                resultssizes=xNew<int>(numberofresults);
     1866                resultstimes=xNew<double>(numberofresults);
     1867                resultssteps=xNew<int>(numberofresults);
    18681868
    18691869                /*populate enums*/
     
    32523252        /*Free ressources:*/
    32533253        delete gauss;
    3254         xfree((void**)&doflist);
     3254        xDelete<int>(doflist);
    32553255}
    32563256/*}}}*/
     
    32913291        /*Free ressources:*/
    32923292        delete gauss;
    3293         xfree((void**)&doflist);
     3293        xDelete<int>(doflist);
    32943294}
    32953295/*}}}*/
     
    33533353
    33543354        /*Free ressources:*/
    3355         xfree((void**)&doflist);
     3355        xDelete<int>(doflist);
    33563356
    33573357}
     
    34133413
    34143414        /*Free ressources:*/
    3415         xfree((void**)&doflist);
     3415        xDelete<int>(doflist);
    34163416}
    34173417/*}}}*/
     
    34513451
    34523452        /*Clean up and return*/
    3453         xfree((void**)&control_type);
     3453        xDelete<int>(control_type);
    34543454}
    34553455/*}}}*/
     
    35693569        }
    35703570
    3571         xfree((void**)&responses);
     3571        xDelete<int>(responses);
    35723572}
    35733573/*}}}*/
     
    44284428        /*Clean up and return*/
    44294429        delete gauss;
    4430         xfree((void**)&responses);
     4430        xDelete<int>(responses);
    44314431        return pe;
    44324432}
     
    46074607        /*Clean up and return*/
    46084608        delete gauss;
    4609         xfree((void**)&responses);
     4609        xDelete<int>(responses);
    46104610        return pe;
    46114611}
     
    47844784        /*Clean up and return*/
    47854785        delete gauss;
    4786         xfree((void**)&responses);
     4786        xDelete<int>(responses);
    47874787        return pe;
    47884788}
     
    49564956
    49574957        /*Free ressources:*/
    4958         xfree((void**)&doflist);
     4958        xDelete<int>(doflist);
    49594959}
    49604960/*}}}*/
     
    49854985
    49864986        /*Free ressources:*/
    4987         xfree((void**)&doflist);
     4987        xDelete<int>(doflist);
    49884988}
    49894989/*}}}*/
     
    52955295        /*Free ressources:*/
    52965296        delete gauss;
    5297         xfree((void**)&doflist);
     5297        xDelete<int>(doflist);
    52985298}
    52995299/*}}}*/
     
    53235323
    53245324        /*Free ressources:*/
    5325         xfree((void**)&doflist);
     5325        xDelete<int>(doflist);
    53265326}
    53275327/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/TriaRef.cpp

    r12365 r12458  
    3434
    3535        /*Only allocate pointer*/
    36         element_type_list=(int*)xmalloc(nummodels*sizeof(int));
     36        element_type_list=xNew<int>(nummodels);
    3737
    3838}
     
    4040/*FUNCTION TriaRef::~TriaRef(){{{*/
    4141TriaRef::~TriaRef(){
    42         xfree((void**)&element_type_list);
     42        xDelete<int>(element_type_list);
    4343}
    4444/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.