in reply to Passing a string from C to Perl

In your petition you touch on one concern without recognising the more serious side of it. There is a design problem with your C function. It has a buffer overflow waiting to happen. Whether it's exploitable depends on the rest of your code, but a too-long error message may (depending on details of your system malloc() and cc ) cause segfaults, memory corruption, stack smashes, or trouble at work.

If the C function is declared as : int myfunction(char** errorstring);you can assign *errorstring within the function after mallocing to fit and copying your string to the new buffer.

I regret that I don't yet know enough xs and perlguts to advise you on what C constructions are most convenient for perl.

After Compline,
Zaxo