doneill has asked for the wisdom of the Perl Monks concerning the following question:
Not the most intuitive I'm certain, but it should suffice: In my .pm file, I have the essential wrappers (and possibly the centre of my woes):MODULE = boink PACKAGE = boink char hello_new( char *woteva ) PREINIT: char *boink; + CODE: printf("Boink::Malloc\n"); boink = malloc( strlen( woteva ) + 3 ); sprintf( boink, "[%s]", woteva ); printf("Boink: Returning '%s'\n", boink ); RETVAL = (int)boink; + void hello_free( char *boink ) CODE: printf("Boink::Free\n"); free( boink );
Then, I have my little test script:my $mres; my $textin; my $ptr; + sub hello { $textin = shift; $$ptr = boink::hello_new( $textin ); + bless $ptr; $mres = $$ptr; + print $mres; + boink::hello_free( $ptr ); + return $mres; }
Ultimately, my result should be:use ExtUtils::testlib; use boink; + boink::hello( "testing\n" );
BUT instead, I get:Boink::Malloc Boink: Returning '[testing ]' [testing ] Boink::Free
Which, is actually what I originally passed /in/ to my subroutine... Any pointers here?Boink::Malloc Boink: Returning '[testing ]' testing Boink::Free
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My XS pointer problem...
by MarkM (Curate) on Apr 08, 2003 at 02:21 UTC | |
by doneill (Initiate) on Apr 08, 2003 at 15:55 UTC |