Ignore:
Timestamp:
08/14/12 17:12:51 (13 years ago)
Author:
Mathieu Morlighem
Message:

CHG: getting rid of xmalloc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/modules/Chaco/Chaco.cpp

    r13036 r13038  
    5454        nvtxs = mxGetN(A_IN);
    5555        mwstart = mxGetJc(A_IN);
    56         start=(int*)xmalloc((nvtxs+1)*sizeof(int));
     56        start=xNew<int>((nvtxs+1));
    5757        for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i];
    5858
    5959        mwadjacency = mxGetIr(A_IN);
    60         adjacency = (int*)xmalloc(mxGetNzmax(A_IN)*sizeof(int));
     60        adjacency = xNew<int>(mxGetNzmax(A_IN));
    6161        for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i];
    6262
    6363        nedges = start[nvtxs];
    6464        if(!mxIsEmpty(EWGTS_IN)){
    65                 ewgts = (float*)xcalloc(nedges, sizeof(float));
     65                ewgts = xNewZeroInit<float>(nedges);
    6666                doublepointer=mxGetPr(A_IN);
    6767                for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i];
     
    7777        for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options
    7878        FetchData(&npart,NPARTS_IN);
    79         nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
     79        nparts=xNew<int>(1); nparts[0]=npart; //weird Chacox interface ain't it?
    8080        FetchData(&goal,&nterms,GOAL_IN);
    8181       
     
    104104       
    105105        /*Allocate output: */
    106         assignment = (short*)xcalloc(nvtxs, sizeof(short));
     106        assignment = xNewZeroInit<short>(nvtxs);
    107107       
    108108    /*Call core: */
     
    110110
    111111    /*Output data: */
    112         doubleassignment=(double*)xmalloc(nvtxs*sizeof(double));
     112        doubleassignment=xNew<double>(nvtxs);
    113113        for(i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i];
    114114        WriteData(ASSGN_OUT,doubleassignment,nvtxs);
Note: See TracChangeset for help on using the changeset viewer.