the problem is that I don't know how would that affect memory handling
That is why I said (emphasis added):
or grab output.c_str() for the XS to copy into the returned PV for the other
You write a C++ function that has a lexical std::string that it passes to the method for the method to fill in. Then you copy the value from output.c_str() to a Perl PV (part of an SV). The handling of a RETVAL of type "char*" will do this copying automatically.
I suppose it becomes a problem if you can't get the XS code to be treated as C++ such that the XS routine is where you declare the output std::string. Though I'm pretty sure this is possible, I also realize that it at least used to be somewhat difficult, requiring some undocumented fiddling.
If I wanted to avoid that complication, then I'd have the middle-man C++ function take two input "char*"s (still) and one output SV* (see your typemap file for the simple incantation required to copy a '\0'-terminated "char*" into the PV of an SV).
- tye
In reply to Re^3: C++ strings, references and XS (char*)
by tye
in thread C++ strings, references and XS
by v01d
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |