diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-17 09:41:41 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-17 09:41:41 +0800 |
commit | 0930b738f5261d4e2630242ca5fa2a6bc63026ff (patch) | |
tree | 42f7b713cbc7b266e5bd28fdf5a36a1888d774c6 | |
parent | b6abbff926e9ff9908935224c1655d94dcc09441 (diff) |
Finally able to typemap char **[] right
For now the item object is still flattened.
-rw-r--r-- | pikul.i | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -19,21 +19,23 @@ } %typemap(in) char **[] { - AV *tempav = (AV *)SvRV($input); - I32 len = av_len(tempav); - $1 = (char ***)malloc((len + 2) * sizeof(char **)); + AV *items = (AV *)SvRV($input); + I32 nitems_min1 = av_len(items); + $1 = (char ***)malloc((nitems_min1 + 2) * sizeof(char **)); int i; - for (i = 0; i <= len; i++) { - AV *av = (AV *)av_fetch(tempav, i, 0); - I32 avlen = av_len(av); - $1[i] = (char **)malloc((avlen + 2) * sizeof(char *)); + for (i = 0; i <= nitems_min1; i++) { + SV **refptr = av_fetch(items, i, 0); + AV *flat = (AV *)SvRV(*refptr); + I32 nattrs_min1 = av_len(flat); + $1[i] = (char **)malloc((nattrs_min1 + 2) * sizeof(char *)); int j; - for (j = 0; j <= avlen; j++) { - SV **tv = av_fetch(av, j, 0); + for (j = 0; j <= nattrs_min1; j++) { + SV **tv = av_fetch(flat, j, 0); $1[i][j] = (char *)SvPV(*tv, PL_na); } $1[i][j] = NULL; } + $1[i] = NULL; }; %typemap(freearg) char **[] { free($1); |