473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

malloc'ed PyTypeObject

Hi,

I'm doing my first project on embedding and then extending Python in
an application. The idea is to import a set of C++ plug-ins into Python
and then be able to run a script that uses these plug-ins. Please note
that what I'm importing into Python are the plug-in classes in order to
be able to instanciate as many objects as needed.

As usual, all the plug-ins derive from a base class. But two
important things differ for each plug-in, its name and a set of
parameters.

For instance, the C++ class

class SNRFilter : public BaseFilter
{
...
};

can be instanciated in a Python script as

snr = SNRFilter()

(This is a quite simplified example as there is also a quite trivial
SNRFilterClass class deriving fron BaseFilterClass. But those are
implementation details).

So, everything works OK, but there will probably be a memory issue.
Each time I add a plug-in class into Python, I malloc a PyTypeObject
and copy its contents from a template static PyTypeObject. Then I
malloc and assign its tp_name and its tp_getset (array of PyGetSetDef).

Now the question is, how can I be sure that all this memory will be
properly free'd after calling Py_Finalize()? Is it enough to add
Py_TPFLAGS_HEAPTYPE? Can I safely free tp_getset after calling
PyType_Ready()? What will the weather be for the next week-end?

Thank you for reading.

--
Gabriel de Dietrich

Apr 6 '06 #1
0 1235

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Woodster | last post by:
I knoew that free is usually paired with malloc and delete is usually paired with malloc, alloc or similar. Can I use delete with malloc? The main reason I ask is for using the strdup function....
0
by: Simon Nickerson | last post by:
I have a function which looks like this: void rho(matrix_t *out, matrix_t *in) { static int firsttime = 1; static matrix_t *words; /* ... other variables ... */ if (firsttime) { firsttime...
14
by: dam_fool_2003 | last post by:
Friends, cannot we malloc a array? So, I tried the following code: int main(void) { unsigned int y={1,3,6},i,j; for(i=0;i<3;i++) printf("before =%d\n",y); *y = 7; /* 1*/
11
by: Sushil | last post by:
Hi Gurus I've tried to come up with a small logical example of my problem. The problem is platform specific (MIPS) which I understand should not be discussed here. So here goes my example: ...
33
by: apropo | last post by:
what is wrong with this code? someone told me there is a BAD practice with that strlen in the for loop, but i don't get it exactly. Could anyone explain me in plain english,please? char...
5
by: Bidule | last post by:
Hi, I'm trying to sort structs defined as follows: struct combinationRec { float score; char* name; }; The number of structs and the length of the "name" field are not known
3
by: Khookie | last post by:
Hi everyone I'm not sure whether this is good practice or not, so I thought I'll ask. I've got a function that returns a char pointer, which is malloc'ed in the function itself, as per below...
2
by: Khookie | last post by:
Hi all I was wondering whether there was a way to know whether a pointer (in my case, I'm using a char pointer) has been allocated memory through malloc or not, thus needing to be freed at a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.