Hi,
With the help of this group I got $! to work, now here is another problem...
I would like to make this work in perl XS:
void init(str)
char * &str
void fill(str, str2)
char * str
char * str2
void free(str)
char * str
void init(char *str) {
*str = (char *)calloc(20, sizeof(char));
}
void fill(char *str, char *str2) {
strcpy(str, str2);
}
void free(char *str) {
free(str);
}
Now in perl I could simply do:
my $test_string; # $test_string is undefined...
init(\$test_string); # now $test_string should be defined but empty...
print "$test_string \n"; # Should print nothing...
fill($test_string, "Hello World!");
print "$test_string \n"; # Should print "Hello World!"
free($test_string); # Now $test_string should be undefined
The char ** is to be considered as a pointer to a string and not a table of
strings (hence the char * &str in init()).
I'm not sure if I \$test_string is sufficient or if I should rather do $tmp;
$test_string = \$tmp;
What would I put in my typemap file to handle freely the conversion between
char ** and perl in this special case, would T_PACKED work? I would
especialy like to "undefine" a perl variable in C. Is this possible?
Thanks!
Daniel Shane