Perl XS

Jeff Butera jvbDS at helios.hampshire.edu
Wed Sep 18 22:44:22 CDT 2002


Anyone have any experience using Perl XS?

I need to call a C function from Perl and have worked thru
the demos in the perlxs tutorial.  The function I need to
call has all strings (character arrays) as it's arguments
and, of course, many are output, such as

int foo(char * a) {
  strcpy(a,"hi there");
  return strlen(a);
}

Of course, a C function like this presumes that the pointer a
has had appropriate memory malloc'ed ahead of time.

Everytime I try to run the test, I get a seg fault which I presume
is due to memory management issues.  That is, from perl this would be 
called something like:

$i=&MyLib::foo($a);

How do I ensure that the proper memory for $a has been allocated
prior to the call to foo?

-- 
Jeff Butera, Ph.D.
Administrative Systems (Computing)
Hampshire College
jbutera at hampshire.edu
413-559-5556

"Let's make that zippy and quick."   
                                Bob Crowley

"...to promote the advancement and diffusion of knowledge..."
                                Andrew Carnegie Foundation



More information about the Pioneer-valley-pm mailing list