Doesn't it suck that if you want a string pointer, and its length, in XS, you need to get the SV * and do the SvPV manually each time? Fear no more. Below typemap will give you the char * pointer, and the length. Always.
void
Foo( str )
char * str
PPCODE:
Foo(str, strLen);
Change the typemap entry to your liking. Also note caching SV * to avoid numerous ST macros in SvPV macro. Who wants to calculate the same thing half a dozen times? Also less noise in your debugger with the now useless SV * being gone.
T_STR_AND_LEN
".(unshift(@line, (
'PREINIT:',
' unsigned long '.$var.'Len;',
'INPUT:')),'').
"{
SV * TmpSV = $arg;
$var = ($type) SvPV( TmpSV , ${\$var}Len);
};
Warning, you must use PREINIT for your XSUBs. Lazy coders shall die.
edited: spelling