From jvbDS at helios.hampshire.edu Wed Sep 18 22:44:22 2002 From: jvbDS at helios.hampshire.edu (Jeff Butera) Date: Thu Aug 5 00:18:41 2004 Subject: Perl XS Message-ID: <200209190344.g8J3iM304839@jeff.hampshire.edu> 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@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