30 Aug 2002 03:16
Two Char **OUTPUT return values not working
Jesse Wolfe <jesse <at> jm-wolfe.com>
2002-08-30 01:16:58 GMT
2002-08-30 01:16:58 GMT
Hi All...
I just am getting into SWIG... it's very cool. I'm using it to interface
into a third-party C library, for use in Perl.
The problem is, I have a function that returns several arrays of character
strings. I thought I could use the Perl code given in the SWIG Perl5 page
from the distribution, under typedefs... the argv example.
Two questions... one was a typo I think...
Here's the (in) code from the example:
%module argv
// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
AV *tempav;
I32 len;
int i;
SV **tv;
if (!SvROK($input))
croak("Argument $argnum is not a reference.");
if (SvTYPE(SvRV($input)) != SVt_PVAV)
croak("Argument $argnum is not an array.");
tempav = (AV*)SvRV($input);
len = av_len(tempav);
$1 = (char **) malloc((len+2)*sizeof(char *));
for (i = 0; i <= len; i++) {
tv = av_fetch(tempav, i, 0);
(Continue reading)
RSS Feed