how to free memory allocated by a function call via ctypes

T

Tzury Bar Yochay

Hi,

Suppose I have the following function
char *generateMessage(char *sender, char *reciever, char *message) ;

now in c I would normally do

char *msg = generateMessage(sender, reciever, message);
// do something
free(msg);

My question is how do I free the memory allocated when I call this
function using ctypes
I could not find this in the documentation for python 2.5

thanks
 
B

Benjamin Peterson

Tzury Bar Yochay said:
My question is how do I free the memory allocated when I call this
function using ctypes

The return type of ctypes.create_string_buffer() will call free() when it is
garbage collected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top