It looks like you have a few problems, the first of which being that "CODE:" XS sections, although defining RETVAL, do not use RETVAL as the default OUTPUT argument. An explicit "OUTPUT: RETVAL" is necessary.
The next problem that you will hit is that you are returning a 'char', casting a malloc()'d pointer to an 'int', and assuming that you can dereference this from Perl. You should be returning a 'char *' or 'SV *' instead.
I recommend a little more reading up on the XS interface. It is very complicated stuff. Cheers, and good luck.