Ignore:
Timestamp:
04/18/12 15:17:58 (13 years ago)
Author:
Mathieu Morlighem
Message:

ALWAYS use Matlab's memory manager in mex modules

File:
1 edited

Legend:

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

    r8963 r12050  
    7474                nel=mxGetM(prhs[0]);
    7575                tindex_in=mxGetPr(prhs[0]);
    76                 index_in=(double*)xmalloc(nel*3*sizeof(double));
     76                index_in=(double*)mxMalloc(nel*3*sizeof(double));
    7777                for (i=0;i<nel;i++){
    7878                        for (j=0;j<3;j++){
     
    9090                nods=mxGetM(prhs[1]);
    9191                x_inm=mxGetPr(prhs[1]);
    92                 x_in=(double*)xmalloc(nods*sizeof(double));
     92                x_in=(double*)mxMalloc(nods*sizeof(double));
    9393                for (i=0;i<nods;i++){
    9494                        x_in[i]=x_inm[i];
     
    103103        if(mxIsDouble(prhs[2])){
    104104                y_inm=mxGetPr(prhs[2]);
    105                 y_in=(double*)xmalloc(nods*sizeof(double));
     105                y_in=(double*)mxMalloc(nods*sizeof(double));
    106106                for (i=0;i<nods;i++){
    107107                        y_in[i]=y_inm[i];
     
    117117                num_seg=mxGetM(prhs[3]);
    118118                tsegments_in=mxGetPr(prhs[3]);
    119                 segments_in=(double*)xmalloc(num_seg*3*sizeof(double));
     119                segments_in=(double*)mxMalloc(num_seg*3*sizeof(double));
    120120                for (i=0;i<num_seg;i++){
    121121                        for (j=0;j<3;j++){
     
    132132        if(mxIsDouble(prhs[4])){
    133133                tsegmentmarkers_in=mxGetPr(prhs[4]);
    134                 segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double));
     134                segmentmarkers_in=(double*)mxMalloc(num_seg*sizeof(double));
    135135                for (i=0;i<num_seg;i++){
    136136                        segmentmarkers_in[i]=tsegmentmarkers_in[i];
     
    270270                        pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
    271271                        mxSetM(pmxa_array2,1);
    272                         pair=(double*)xmalloc(2*sizeof(double));
     272                        pair=(double*)mxMalloc(2*sizeof(double));
    273273                        pair[0]=*(out_riftstips+2*i+0);
    274274                        pair[1]=*(out_riftstips+2*i+1);
     
    293293
    294294                        /*State: */
    295                         state=(double*)xmalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
     295                        state=(double*)mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
    296296                        for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum;
    297297                        pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
     
    306306        else{
    307307                /*output NaN :*/
    308                 pNaN=(double*)xmalloc(sizeof(double));
     308                pNaN=(double*)mxMalloc(sizeof(double));
    309309                *pNaN=NAN;
    310310                pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
Note: See TracChangeset for help on using the changeset viewer.