Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to free memory allocated by a function call via ctypes

Reply
Thread Tools

how to free memory allocated by a function call via ctypes

 
 
Tzury Bar Yochay
Guest
Posts: n/a
 
      05-30-2009
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
 
Reply With Quote
 
 
 
 
Benjamin Peterson
Guest
Posts: n/a
 
      05-30-2009
Tzury Bar Yochay <Afro.Systems <at> gmail.com> writes:
>
> 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.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ctypes free memory which is allocated in C DLL zlchen.ken@gmail.com Python 6 10-28-2012 02:05 AM
Allocating memory to pass back via ctypes callback function Scott Python 1 06-19-2009 11:14 AM
Dynamically Allocated Memory vs. Statically allocated Memory csnerd@gmail.com C++ 5 12-09-2004 01:44 AM
how to free the allocated memory outside of the function madhur C Programming 6 06-28-2004 10:37 AM



Advertisments