Changeset 12429


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

changing xmalloc to xNew and xfree to xDelete

Location:
issm/trunk-jpl/src/c/toolkits
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/issm/SeqMat.cpp

    r12365 r12429  
    3333        this->N=pN;
    3434        this->matrix=NULL;
    35         if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
     35        if(M*N) this->matrix=xNewInit<double>(pM*pN,0.0);
    3636}
    3737/*}}}*/
     
    4242        this->N=pN;
    4343        this->matrix=NULL;
    44         if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
     44        if(M*N) this->matrix=xNewInit<double>(pM*pN,0.0);
    4545}
    4646/*}}}*/
     
    5454        this->matrix=NULL;
    5555        if(M*N){
    56                 this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
     56                this->matrix=xNewInit<double>(pM*pN,0.0);
    5757                memcpy(this->matrix,serial_mat,pM*pN*sizeof(double));
    5858        }
     
    6666        this->N=pN;
    6767        this->matrix=NULL;
    68         if(M*N)this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
     68        if(M*N) this->matrix=xNewInit<double>(pM*pN,0.0);
    6969}
    7070/*}}}*/
     
    7272SeqMat::~SeqMat(){
    7373
    74         xfree((void**)&this->matrix);
     74        xDelete<double>(this->matrix);
    7575        M=0;
    7676        N=0;
     
    178178
    179179        if(this->M*this->N){
    180                 buffer=(double*)xmalloc(this->M*this->N*sizeof(double));
     180                buffer=xNew<double>(this->M*this->N);
    181181                memcpy(buffer,this->matrix,this->M*this->N*sizeof(double));
    182182        }
  • issm/trunk-jpl/src/c/toolkits/issm/SeqVec.cpp

    r12365 r12429  
    3131        this->M=pM;
    3232        this->vector=NULL;
    33         if(this->M) this->vector=(double*)xcalloc(pM,sizeof(double));
     33        if(this->M) this->vector=xNewInit<double>(pM,0.0);
    3434}
    3535/*}}}*/
     
    4242        this->vector=NULL;
    4343        if(this->M){
    44                 this->vector=(double*)xcalloc(pM,sizeof(double));
     44                this->vector=xNewInit<double>(pM,0.0);
    4545                memcpy(this->vector,buffer,pM*sizeof(double));
    4646        }
     
    4949                /*FUNCTION SeqVec::~SeqVec(){{{*/
    5050SeqVec::~SeqVec(){
    51         xfree((void**)&this->vector);
     51        xDelete<double>(this->vector);
    5252        M=0;
    5353}
     
    170170
    171171        if(this->M){
    172                 buffer=(double*)xmalloc(this->M*sizeof(double));
     172                buffer=xNew<double>(this->M);
    173173                memcpy(buffer,this->vector,this->M*sizeof(double));
    174174        }
  • issm/trunk-jpl/src/c/toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp

    r10087 r12429  
    1313        METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, index, petype, pnumflag, pnum_procs, pedgecut, epart, npart);
    1414        #elif _METIS_VERSION_ == 5
    15         /*This interface is heavily changed. More options, different way of meshing, etc ...: */
     15        /*This interface is heavily changed. More options, different ways of meshing, etc ...: */
    1616        int i;
    1717
     
    2121        idx_t  k=0;
    2222        real_t* tpwgts=NULL;
    23 
    24 
    2523
    2624        /*setup options: */
     
    4038        options[METIS_OPTION_NCUTS]   = 1;
    4139
    42 
    4340        /*create eptr: */
    44         eptr=(idx_t*)xmalloc((*pnumberofelements+1)*sizeof(idx_t));
     41        eptr=xNew<idx_t>((*pnumberofelements+1));
    4542        eptr[0]=0;
    4643        for(i=0;i<*pnumberofelements;i++){
     
    4946        }
    5047
    51 
    5248        /*create tpwgts: */
    53         tpwgts=(real_t*)xmalloc(*pnum_procs*sizeof(real_t));
     49        tpwgts=xNew<real_t>(*pnum_procs);
    5450        for(i=0;i<*pnum_procs;i++){
    5551                tpwgts[i]=1.0/(*pnum_procs);
    5652        }
    5753
    58 
    5954        METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, eptr, index,
    60                         NULL, NULL, pnum_procs, tpwgts, options, &objval,
    61                         epart, npart);
    62        
     55                        NULL, NULL, pnum_procs, tpwgts, options, &objval,epart, npart);
    6356
    6457        #else
  • issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp

    r11695 r12429  
    55#include <stdio.h>
    66#include <math.h>
    7 
    8 
    97#include "../../../shared/shared.h"
    108
     
    2422       
    2523        /*We are  not bound by any library, just use what seems most logical*/
    26         num_local_rows=(int*)xmalloc(num_procs*sizeof(int));   
     24        num_local_rows=xNew<int>(num_procs);   
    2725
    2826        for (i=0;i<num_procs;i++){
    29 
    3027                /*Here, we use floor. We under distribute rows. The rows
    3128                  left  are then redistributed, therefore resulting in a
     
    3936                num_local_rows[i]++;
    4037        }
    41 
    4238        local_size=num_local_rows[my_rank];
    4339       
    4440        /*free ressources: */
    45         xfree((void**)&num_local_rows);
     41        xDelete<double>(num_local_rows);
    4642
    4743        /*return size: */
  • issm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp

    r11695 r12429  
    2020
    2121        /*Gather all range values into allranges, for all nodes*/
    22         allranges=(int*)xmalloc(num_procs*sizeof(int));
     22        allranges=xNew<int>(num_procs);
    2323        MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
    24 
    2524
    2625        /*From all ranges, get lower row and upper row*/
     
    3130                upper_row=upper_row+allranges[i];
    3231        }
    33        
    34         /*free: */
    35         xfree((void**)&allranges);
    3632
    3733        /*Assign output pointers: */
     34        xDelete<double>(allranges);
    3835        *plower_row=lower_row;
    3936        *pupper_row=upper_row;
    40 
    4137        return 1;
    4238}
Note: See TracChangeset for help on using the changeset viewer.