perl memry free problem

Discussion in 'Perl Misc' started by sachin, Apr 29, 2004.

  1. sachin

    sachin Guest

    Hi All

    I have written a perl extension for a library mymodule I have used
    swig to genarate this .
    In this module there is a function get_prop which has one in
    parameter and two out parameter

    sub get_obj_prop {
    ($ret,$prop,) =&mymodule::get_prop($obj);
    if($ret==$mymodule::MY_EOK) {
    print "OK \n";
    }
    else {
    print "Error $ret \n";
    }
    }

    all variables have a global scope
    $prop is a pointer to struct obj_prop

    $prop is a pointer to a structure allocated by the library
    when i call this function second time or i assign some other prop
    structure pointer like
    $prop = $prop1;
    the perl internally calls
    the delete_obj_prop function which deletes the structure pointed by
    $prop
    I dont want such thing to happen because the library internally takes
    care of the allocated memory the library maintains the cache of the
    allocated memory
    Is there is any way so that i can prevent perl from freeing the
    structure

    Thanks in advance
    Sachin.
     
    sachin, Apr 29, 2004
    #1
    1. Advertising

  2. sachin wrote:
    >
    > all variables have a global scope
    > $prop is a pointer to struct obj_prop
    >
    > $prop is a pointer to a structure allocated by the library
    > when i call this function second time or i assign some other prop
    > structure pointer like
    > $prop = $prop1;
    > the perl internally calls
    > the delete_obj_prop function which deletes the structure pointed by


    If you reassign $prop then the reference count of to whatever it was
    pointing is reduced by one, and if there are no other references to that
    object then it is liable to be garbage-collected. Or am I misreading this?

    Mark
     
    Mark Clements, Apr 29, 2004
    #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. mutant
    Replies:
    0
    Views:
    466
    mutant
    Nov 27, 2005
  2. sathyashrayan
    Replies:
    1
    Views:
    319
    Peter Koch Larsen
    Feb 20, 2005
  3. george
    Replies:
    0
    Views:
    1,197
    george
    Aug 29, 2008
  4. mohammed_a_o
    Replies:
    0
    Views:
    319
    mohammed_a_o
    Nov 30, 2010
  5. Replies:
    2
    Views:
    196
    Brian McCauley
    Dec 22, 2005
Loading...

Share This Page