[Bf-python] Mesh Module
Willian Padovani Germano
wgermano at superig.com.br
Thu Oct 6 23:17:09 CEST 2005
Ken Hughes wrote:
> typedef struct BPy_MVert {
> PyObject_VAR_HEAD
> int index;
> void *data;
> } PyVert;
> Do you feel that PyVerts should be completely separate type, even though
> the attribute operations are basically identical? I could reuse the
> attribute code and just present two different PyType structures (and
> PyGetSetDef tp_getseters, one without the index attribute), or make them
> totally separate and identical....
Are you using a malloc (MEM_mallocN or the Python malloc or the libc
one) to get memory for data?
The idea is to let Python handle all the allocated memory, getting rid
of it when the pyobject's refcount reaches zero. We've had a few issues
using MEM_mallocN (string buttons in Draw.c, for example, of course the
problem happens with any malloc, not just Blender's), even when freeing
the memory in the object's deallocator, because of things like this:
Button(...) # no asignment, somehow the reference is lost
instead of
mybutton = Button(...) # ok
But if you don't get any issues (I haven't followed the issues with
bones and curves, Stephen, Joseph and you can comment better), I see no
problems with the approach you chose (since you made vert.index
read-only). Just make sure to use Blender's mem handling functions, in
case you need a malloc, for example. It complains out load when
something goes wrong, you know.
--
Willian
More information about the Bf-python
mailing list