Re: Questions about Inline::C
- From: "Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Sep 2006 19:33:41 +1000
"January Weiner" <january.weiner@xxxxxxxxx> wrote in message
..
..
I mean, is there is any danger with malloc() from within Inline::C
that is not present in regular C programs
Yes, I believe so - not sure of the details but I think it has something to
do with the possibility that perl has been compiled with its own malloc()
function.
Instead of malloc(), use New(). (See 'perldoc perlapi'.)
There are some *other* C functions that it's best to avoid, too - in favour
of their perl API equivalents. See 'perldoc perlclib'
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).
In perl you can quote string literals inside either single or double
quotes - but in C you have to use double quotes. Using single quotes will
inevitably result in some sort of error. (I get a segfault, too.)
newSVpv() has to take 2 arguments - see (again) 'perldoc perlapi'.
Cheers,
Rob
.
- Follow-Ups:
- Re: Questions about Inline::C
- From: January Weiner
- Re: Questions about Inline::C
- References:
- Questions about Inline::C
- From: January Weiner
- Questions about Inline::C
- Prev by Date: Re: FTP from Perl script on Windows
- Next by Date: Re: Questions about Inline::C
- Previous by thread: Re: Questions about Inline::C
- Next by thread: Re: Questions about Inline::C
- Index(es):
Relevant Pages
|