[Dub-pm] big data structures relative to memory size

Sean O'Riordain seanpor at acm.org
Fri Apr 16 14:58:40 CDT 2004

ah ha! thank you! i went through the cookbook yesterday a few times but 
didn't get it...  the missing piece was "you create a Perl scalar in 
your C code and stuff the pointer into that and return that to Perl." 
hmmm... obvious when you say it! seems like a day for it!

i'm not sure i understand the blessed objects bit... initially i'll have 
a go at doing my own memory management and see how i go...

I'll report back to dublin-pm with the results  - it might be a few 
days... :-)


Fergal Daly wrote:

>Yeah, that's it. Have a look at the Inline::C cookbook for full details but
>very briefly you create a Perl scalar in your C code and stuff the pointer
>into that and return that to Perl. If you don't want to worry about garbage
>collection then you should make sure that the scalar is a blessed object and
>that it's DESTROY method calls something to free the memory. There's geansai
>loads of examples in the docs although to be honest the one or two times I
>wanted to mix Perl and C I ended up using XS. Inline::C was storing lots of
>crap in hidden directories and some other stuff that I didn't like - can't
>remember what anymore so maybe my gripes no longer exist. Give it a whirl
>anyway, the examples are great,
>On Fri, Apr 16, 2004 at 05:15:26PM +0100, Sean O'Riordain wrote:
>>Hi Fergal!
>>have to think about that one!
>>if i malloc memory in C then go back to perl to pass info into C 
>>again... how do i reference that memory again - i presume i pass the 
>>info back and forth by reference, - or could it be still available as a 
>>static type pointer... i'm missing a step here...

More information about the Dublin-pm mailing list