Source

perlxs / test.xs

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <stdlib.h>

char** test_func(int a, int* b);

MODULE = test		PACKAGE = test		

SV *
testfunc(a, b)
    int a
    int b
    PREINIT:
        char **string_list;
        char **str;
        int len;

    PPCODE:
        string_list = test_func(a, &b);
        if (string_list != NULL) {
            for (len = 0; string_list[len] != NULL; len += 1);

            EXTEND(SP, len);
            for (str = string_list; *str != NULL; str += 1) {
                PUSHs(newSVpv(*str, 0));
                free(*str);
            }
            free(string_list);
        }