Questions about Inline::C
- From: January Weiner <january.weiner@xxxxxxxxx>
- Date: Thu, 28 Sep 2006 09:58:04 +0200 (CEST)
Dear all,
I had to revert to C again. Since the thought of parsing all my files in C
was dreadful, I decided to use Inline::C to only do the job that was really
computationally intensive. Currently, my program seems to run quite well,
I am very happy with Inline::C, and a little coding in C made me bless
Larry again and again.
There are, however, few questions that remain open.
1. In the Inline::C cookbook, it says
> I would urge you to stay away from "malloc"ing your own buffer. Just
> use Perl's built in memory management. In other words, just create a
> new Perl string scalar. The function "newSVpv" does just that. And
> "newSVpvf" includes "sprintf" functionality.
Why? I mean, is there is any danger with malloc() from within Inline::C
that is not present in regular C programs, or is it because using malloc
is just generally tricky? I much prefer to do the allocation myself,
as I know exactly how large my matrix is and as I want to allocate the
whole matrix ( say, double 2000 x 2000 ) in one go myself. The reason is
that I fear that using perl guts for my calculations (accessing the
matrix, calculating values in it etc.) will be not much slower than a
simple C implementation. Maybe I am wrong, I haven't tested it.
Furthermore, I feel more comfortable using things that I know well, even
thought they might turn dangerous.
2. When using Inline_Stack to return a list to Perl code, I found that the
following throws a segfault:
Inline_Stack_Reset ;
Inline_Stack_Push( sv2_mortal( newSVpv( 'score' ) ) ) ;
Inline_Stack_Done ;
...while the following does not:
Inline_Stack_Reset ;
Inline_Stack_Push( sv2_mortal( newSVpv( "score" ) ) ) ;
Inline_Stack_Done ;
Should I be worried, or is it normal behaviour? (I tried to look up the
definition of Inline_Stack_Push, but I have trouble finding it).
Cheers,
January
--
.
- Follow-Ups:
- Re: Questions about Inline::C
- From: Sisyphus
- Re: Questions about Inline::C
- From: Mirco Wahab
- Re: Questions about Inline::C
- Prev by Date: FAQ 1.2 Who supports Perl? Who develops it? Why is it free?
- Next by Date: FTP from Perl script on Windows
- Previous by thread: FAQ 1.2 Who supports Perl? Who develops it? Why is it free?
- Next by thread: Re: Questions about Inline::C
- Index(es):
Relevant Pages
|