Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Should the op 'pin' create a C-string ?

3 views
Skip to first unread message

Bernhard Schmalhofer

unread,
Nov 10, 2004, 5:55:26 PM11/10/04
to perl6-l...@perl.org
Hi,

I am trying to pass a string, containing YAML, from Parrot to the shared
library 'libsyck'.

'libsyck' provides two functions:

void syck_parser_str( SyckParser *, char *, long, SyckIoStrRead ); (
v_ptip )
SYMID syck_parse( SyckParser * ); ( i_p
)

'syck_parser_str' tells libsyck about the string to be parsed.
'syck_parse' does the parsing.
This means that the string buffer has to stay around, until the parsing is
done.

Currently, when calling 'syck_parser_str', the string buffer is copied into
newly allocated system memory. In order to avoid memory leaks, this
allocated system memory is freed immediately after 'syck_parser_str'. Not
surprisingly, bad things are happening when 'syck_parse' is called later.

From strings.pod I gather that the op 'pin' is meant to make strings fit for
passing strings to external libraries. For me it would be convenient, if
'pin' would put a trailing '\0' at the end of the used string buffer. Also a
pinned string shouldn't have to be copied into newly allocated memory.

Is that the right way to go?


--
/* Bernhard.S...@biomax.de */

Geschenkt: 3 Monate GMX ProMail + 3 Top-Spielfilme auf DVD
++ Jetzt kostenlos testen http://www.gmx.net/de/go/mail ++

0 new messages