how to free memory allocated by a function call via ctypes

Discussion in 'Python' started by Tzury Bar Yochay, May 30, 2009.

  1. 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
     
    Tzury Bar Yochay, May 30, 2009
    #1
    1. Advertising

  2. 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.
     
    Benjamin Peterson, May 30, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    628
    Matt Wharton
    Dec 9, 2004
  2. madhur
    Replies:
    6
    Views:
    338
    Prawit Chaivong
    Jun 28, 2004
  3. Panduranga Chary

    How memory function free() knows how much memory to free.

    Panduranga Chary, Dec 27, 2007, in forum: C Programming
    Replies:
    2
    Views:
    428
    Keith Thompson
    Dec 27, 2007
  4. Scott
    Replies:
    1
    Views:
    439
    Scott
    Jun 19, 2009
  5. Replies:
    6
    Views:
    255
Loading...

Share This Page