I'd like to write a C routin which will handle an array reference and a
string as parameter.
The Calling of the routine would look like this:
$result = PPPP::GenHash([EMAIL PROTECTED], $key);
And the routine handling of xs file for this is:
SV *
GenHash(params, key)
PREINIT:
char **pparam;
int pnum;
SV **item;
int i;
char *ckey;
char *hash;
INPUT:
AV * params;
SV * key;
CODE:
pnum = av_len(params);
pparam = (char **) safemalloc( sizeof(char *) * pnum);
for (i=0; i <= pnum ; i++)
{
item = av_fetch(params, i, 0);
pparam[i] = SvPVX(*item);
}
ckey = SvPVX(key);
hash = GenCHash(pparam, ckey);
RETVAL = newSVpv(hash, strlen(hash));
OUTPUT:
RETVAL
The definition of GenCHash C routine is
char * GenCHash(char **params, char const *key)
but after it is compiled and installed and the perl tries to call it, it
fails with
'params is not of type AVPtr in .......'
What could be wrong here?
Thanks for you answer ASAP
Tom