Re: Questions about Inline::C




"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


.



Relevant Pages

  • Re: quotes
    ... > I want to develop and run a perl program on a file which ... > single quotes, double quotes, and apostrophes. ... Apostrophe in Raghu's mistake somehow ...
    (comp.lang.perl.misc)
  • Re: How to "cast" string "1 + 2 + 3" to a number?
    ... >> Perl documentation. ... MV> of double quotes there. ... why are single quotes even in perl ...
    (comp.lang.perl.misc)
  • Re: Changing date field in a text file...
    ... > you understand a little more about the Perl language. ... > seeing those quotes anyway. ... Those two digits will be the day number. ... The regular expression is the contents of the first pair ...
    (comp.unix.shell)
  • Re: Changing date field in a text file...
    ... you understand a little more about the Perl language. ... But the shell "eats" quotes before sending the rest to Perl. ... Those two digits will be the day number. ... The regular expression is the contents of the first pair ...
    (comp.unix.shell)
  • Re: configurable variables in own file?
    ... x> without some compelling reason? ... I was objecting to the use of a Perl programmer as the standard for what ... the double quotes do variable interpolation but otherwise ... so it's best to avoid them unless blah blah blah..." ...
    (comp.lang.perl.misc)