Changeset 4917


Ignore:
Timestamp:
Jan 9, 2008, 2:06:30 PM (17 years ago)
Author:
duncan
Message:

working on memory freeing in the mesh generator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c

    r4916 r4917  
    271271                                         (char*) out.pointlist);
    272272                                           
    273   /*                                             
    274   (double*) genpointlist -> data = out.pointlist;               
    275   ((double*) genpointlist -> data) = out.pointlist;
    276   ( genpointlist -> data) = (double*) out.pointlist;
    277    genpointlist -> data = (double) out.pointlist;
    278  
    279   */
    280  
     273 
    281274  /* Add point marker list */
    282275  dimensions[0] = out.numberofpoints;
     
    336329  }
    337330 
    338   /* Add triangle neighbor list */
    339   /*if (out.neighborlist != NULL) {
    340     listsize = out.numberoftriangles;
    341     holderlist = PyList_New(listsize);
    342     for(i=0; i<listsize;i++){
    343       PyObject *mlist = Py_BuildValue((char *)"(i,i,i)",
    344                                       out.neighborlist[i*3  ],
    345                                       out.neighborlist [i*3+1],
    346                                       out.neighborlist [i*3+2]);   
    347       PyList_SetItem(holderlist,i, mlist);
    348     }   
    349     ii=PyString_FromString("generatedtriangleneighborlist");
    350     PyDict_SetItem(holder, ii, holderlist);
    351     Py_DECREF(ii); Py_DECREF(holderlist);
    352   }   
    353    */
    354  
    355  
    356   /* R = Py_BuildValue((char *)"O", holder); */
     331 
    357332  R = Py_BuildValue((char *)"OOOOOOOO"
    358333                    ,PyArray_Return(gentrianglelist)
     
    365340                    ,PyArray_Return(genneighborlist)
    366341                    );
    367    /*Py_DECREF(holder);* This fixed a  memory problem ticket#189 */
     342                   
    368343  Py_DECREF(gentrianglelist);
    369344  Py_DECREF(genpointlist);
     
    376351 
    377352 
    378   /* Free in/out structure memory */
    379   /* OUT
    380 
     353  /* These memory blocks are passed into Numeric arrays
     354   so don't free them  */
     355  /*
     356  if(!out.trianglelist){   
     357    free(out.trianglelist); out.trianglelist=NULL;
     358   
     359   
    381360  if(!out.pointlist){
    382361    free(out.pointlist);  out.pointlist=NULL;
    383   }
     362  } 
     363 
    384364  if(!out.pointmarkerlist){   
    385365    free(out.pointmarkerlist); out.pointmarkerlist=NULL;
    386366  }
     367 
    387368  if(!out.pointattributelist){   
    388369    free(out.pointattributelist); out.pointattributelist=NULL;
    389370  }   
    390   if(!in.pointattributelist){   
    391     free(out.pointattributelist); out.pointattributelist=NULL;
    392   }   
    393   if(!out.trianglelist){   
    394     free(out.trianglelist); out.trianglelist=NULL;
    395   }
     371 
    396372  if(!out.triangleattributelist){   
    397373    free(out.triangleattributelist); out.triangleattributelist=NULL;
    398374  }
     375  if(!out.segmentlist){
     376    free(out.segmentlist); out.segmentlist =NULL;
     377  }
     378  if(!out.segmentmarkerlist){
     379    free(out.segmentmarkerlist); out.segmentmarkerlist  =NULL;
     380  }
     381  if(!out.neighborlist){   
     382    free(out.neighborlist); out.neighborlist=NULL;
     383  }
     384   */
     385
     386   
     387 
     388  /* Free in/out structure memory */
     389 
    399390  if(!out.trianglearealist){   
    400391    free(out.trianglearealist); out.trianglearealist=NULL;
    401392  }
    402   if(!out.neighborlist){   
    403     free(out.neighborlist); out.neighborlist=NULL;
    404   }
    405   if(!out.segmentlist){
    406     free(out.segmentlist); out.segmentlist =NULL;
    407   }
    408   if(!out.segmentmarkerlist){
    409     free(out.segmentmarkerlist); out.segmentmarkerlist  =NULL;
    410   }
    411393  if(!out.edgelist){
    412394    free(out.edgelist);  out.edgelist=NULL;
     
    421403    free(out.regionlist); out.regionlist=NULL;
    422404  }
    423     */
    424405  return R;
    425406}
Note: See TracChangeset for help on using the changeset viewer.