Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > perl memry free problem

Reply
Thread Tools

perl memry free problem

 
 
sachin
Guest
Posts: n/a
 
      04-29-2004
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.
 
Reply With Quote
 
 
 
 
Mark Clements
Guest
Posts: n/a
 
      04-29-2004
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
 
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
free free 100 dollors free 4days only FRee REGISTER ONLy h Computer Support 0 04-17-2008 07:43 AM
free free 100 dollors free 4days only FRee REGISTER ONLy h Digital Photography 0 04-17-2008 07:40 AM
I got a good news here. Free guest book, free URL direct, free counter, free minipoll and much more!!! Why don't you join? cyx.thunderfoot@gmail.com HTML 1 07-06-2005 12:25 PM
Upgrade flash (4 mb memry card) to 827-4v rico Cisco 0 04-14-2005 12:57 PM
Mix memry Peters I.W Computer Support 5 02-10-2005 01:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57