Changeset 12435


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

changing xmalloc to xNew and xfree to xDelete

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/Elements/CoordinateSystemTransform.cpp

    r10532 r12435  
    2727
    2828        /*Allocate and initialize transform matrix*/
    29         transform=(double*)xmalloc(numdofs*numdofs*sizeof(double));
     29        transform=xNew<double>(numdofs*numdofs);
    3030        for(i=0;i<numdofs*numdofs;i++) transform[i]=0.0;
    3131
  • issm/trunk-jpl/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp

    r10529 r12435  
    99
    1010        /*All nodes have the same Coordinate System*/
    11         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     11        cs_array=xNew<int>(numnodes);
    1212        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1313
     
    1616
    1717        /*Clean-up*/
    18         xfree((void**)&cs_array);
     18        xDelete<int>(cs_array);
    1919}
    2020
     
    3636
    3737        /*Copy current stiffness matrix*/
    38         values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
     38        values=xNew<double>(Ke->nrows*Ke->ncols);
    3939        for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
    4040
     
    4949
    5050        /*Free Matrix*/
    51         xfree((void**)&transform);
    52         xfree((void**)&values);
     51        xDelete<double>(transform);
     52        xDelete<double>(values);
    5353}
  • issm/trunk-jpl/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp

    r10523 r12435  
    99
    1010        /*All nodes have the same Coordinate System*/
    11         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     11        cs_array=xNew<int>(numnodes);
    1212        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1313
     
    1616
    1717        /*Clean-up*/
    18         xfree((void**)&cs_array);
     18        xDelete<int>(cs_array);
    1919}
    2020
     
    3636
    3737        /*Copy current stiffness matrix*/
    38         values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
     38        values=xNew<double>(Ke->nrows*Ke->ncols);
    3939        for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
    4040
     
    4949
    5050        /*Free Matrix*/
    51         xfree((void**)&transform);
    52         xfree((void**)&values);
     51        xDelete<double>(transform);
     52        xDelete<double>(values);
    5353}
  • issm/trunk-jpl/src/c/shared/Exp/DomainOutlineRead.cpp

    r12098 r12435  
    1919
    2020        /*I/O: */
    21         FILE* fid=NULL;
    22         char chardummy[256];
     21        FILE   *fid = NULL;
     22        char    chardummy[256];
    2323        double  ddummy;
    2424
    2525        /*output: */
    26         int nprof; //number of profiles in the domainname file
    27         int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles
    28         double** pprofx=NULL; //array of profiles x coordinates
    29         double** pprofy=NULL; //array of profiles y coordinates
    30         bool* closed=NULL; //array holding closed flags for the nprof profiles
     26        int      nprof;                //number of profiles in the domainname file
     27        int     *profnvertices = NULL; //array holding the number of vertices for the nprof profiles
     28        double **pprofx        = NULL; //array of profiles x coordinates
     29        double **pprofy        = NULL; //array of profiles y coordinates
     30        bool    *closed        = NULL; //array holding closed flags for the nprof profiles
    3131
    3232        /*For each profile: */
    33         int n;
    34         double* x=NULL;
    35         double* y=NULL;
    36         bool cl;
     33        int     n;
     34        double *x  = NULL;
     35        double *y  = NULL;
     36        bool    cl;
    3737
    3838        /*open domain outline file for reading: */
     
    6161       
    6262        /*Allocate and initialize all the profiles: */
    63         profnvertices=(int*)xmalloc(nprof*sizeof(int));
    64         pprofx=(double**)xmalloc(nprof*sizeof(double*));
    65         pprofy=(double**)xmalloc(nprof*sizeof(double*));
     63        profnvertices=xNew<int>(nprof);
     64        pprofx=xNew<double*>(nprof);
     65        pprofy=xNew<double*>(nprof);
    6666        for (i=0;i<nprof;i++){
    6767                pprofx[i]=NULL;
    6868                pprofy[i]=NULL;
    6969        }
    70         closed=(bool*)xmalloc(nprof*sizeof(bool));
     70        closed=xNew<bool>(nprof);
    7171
    7272        /*Reaset file pointer to beginning of file: */
     
    9191                y=(double*)xmalloc(n*sizeof(double));
    9292               
    93 
    9493                /*Read vertices: */
    9594                for (i=0;i<n;i++){
     
    118117        *ppprofx=pprofx;
    119118        *ppprofy=pprofy;
    120         if(pclosed)*pclosed=closed;
    121         else       xfree((void**)&closed);
     119        if(pclosed)
     120         *pclosed=closed;
     121        else
     122         xDelete<bool>(closed);
    122123}
    123124
  • issm/trunk-jpl/src/c/shared/Threads/LaunchThread.cpp

    r12292 r12435  
    2020
    2121#include "./issm_threads.h"
    22 #include "../Alloc/alloc.h"
     22#include "../Alloc/xNewDelete.h"
    2323#include "../Exceptions/exceptions.h"
    2424#include "../../include/include.h"
     
    2828        #ifdef _MULTITHREADING_
    2929        int i;
    30         int* status=NULL;
    31 
    32         pthread_t* threads=NULL;
    33         pthread_handle* handles=NULL;
     30        int            *status  = NULL;
     31        pthread_t      *threads = NULL;
     32        pthread_handle *handles = NULL;
    3433       
    3534        /*dynamically allocate: */
    36         threads=(pthread_t*)xmalloc(num_threads*sizeof(pthread_t));
    37         handles=(pthread_handle*)xmalloc(num_threads*sizeof(pthread_handle));
     35        threads=xNew<pthread_t>(num_threads);
     36        handles=xNew<pthread_handle>(num_threads);
    3837
    3938        for(i=0;i<num_threads;i++){
     
    4241                handles[i].num=num_threads;
    4342        }
    44        
    4543        for(i=0;i<num_threads;i++){
    4644
     
    5654       
    5755        /*Free ressources:*/
    58         xfree((void**)&threads);
    59         xfree((void**)&handles);
     56        xDelete<pthread_t>(threads);
     57        xDelete<pthread_handle>(handles);
    6058
    6159        #else
  • issm/trunk-jpl/src/c/shared/shared.h

    r12420 r12435  
    1717#include "Matrix/matrix.h"
    1818#include "Numerics/numerics.h"
    19 #include "Dofs/dofs.h"
    2019#include "Threads/issm_threads.h"
    2120#include "Bamg/shared.h"
Note: See TracChangeset for help on using the changeset viewer.