- Timestamp:
- Dec 21, 2007, 12:44:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c
r4893 r4894 62 62 #include "Python.h" 63 63 64 //#define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 65 66 #define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 67 //#define NO_IMPORT_ARRAY 64 68 #include "Numeric/arrayobject.h" 65 69 #include <sys/types.h> 66 70 67 71 static PyObject *triang_genMesh(PyObject *self, PyObject *args){ … … 214 218 /*printf("\n\nTriangulate input args: %s \n\n", mod); */ 215 219 triangulate(mod, &in, &out, (struct triangulateio *)NULL ); 216 220 221 222 /* 223 PyArray_FromDims allolws you to create a Numeric array with unitialized data. 224 The first argument is the size of the second argument ( 225 the dimensions array). 226 The dimension array argument is just a 1D C array where each element of 227 the array is the size of that dimension. 228 (int dimensions[2] = { 4, 3 }; defines a 4 by 3 array.) 229 The third argument is just the desired type. 230 */ 231 232 //Py_Initialize(); 233 // Testing passing a numeric array out 234 dimensions[0] = 4; 235 // Allocate space for return vectors a and b (don't DECREF) 236 r_test = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE); 237 217 238 /* printf(" *** back from triangulate\n" ); */ 218 239 /* … … 330 351 Py_DECREF(ii); Py_DECREF(holderlist); 331 352 } 332 /* 333 // Testing passing a numeric array out 334 dimensions[0] = 4; 335 // Allocate space for return vectors a and b (don't DECREF) 336 // This is crashing - don't know why 337 r_test = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE); 338 */ 353 354 339 355 340 356 /* Free in/out structure memory */ … … 382 398 } 383 399 384 /*Py_DECREF(holder);*/ 385 R = Py_BuildValue((char *)"O", holder); 386 /*Py_DECREF(holder);* Try this to fix memory problems */ 400 /* R = Py_BuildValue((char *)"O", holder); */ 401 R = Py_BuildValue((char *)"OO", holder, PyArray_Return(r_test)); 402 Py_DECREF(holder); /** This fixed a memory problem ticket#189 */ 403 Py_DECREF(r_test); 387 404 return R; 388 405 } … … 397 414 void initmesh_engine_c_layer(){ 398 415 Py_InitModule((char *)"mesh_engine_c_layer",triang_methods); 416 417 import_array(); // Necessary for handling of NumPY structures 399 418 }
Note: See TracChangeset
for help on using the changeset viewer.