Dan Sugalski wrote:
There are interfaces in the extension system to get a void * and length back from a PMC when fetching string data out, but I see we don't have that for plain strings. I'll probably fix that this weekend if someone doesn't beat me to it.
There was a disucssion WRT that on #parrot today:
Autrijus had implemented:
const char *Parrot_string_cstring(Interp *, const STRING *);
This was in string_funcs.h only albeit it didn't have an Interp* argument originally. It returns str->strstart, which is currently not quite right or safe.
We can do one of: a) return the length additionally to strstart b) internally delimit "C-strings" by an invisibile NUL.
And we have to limit this function for fixed8-encoded strings and make clear that the returned string is immutable.
For other cases we have already string_to_cstring (and an interface in extend.h) which returns a malloced copy of the string.
leo