On Mon, 2004-03-01 at 09:38, Vadim O. Ustiansky wrote: > If, as you said, you store a pointer to the C struct somewhere in an SV, the > raw memory address becomes available at the perl level. The perl programmer > may simply change this value and your C code will not notice it. This just > opens a door at perl level to all headaches known to C pointers.
You might also want to look into Perl Magic. See `perlapi' / "Magical Functions" and sv_magic and sv_unmagic. Using PERL_MAGIC_ext you simply have to cast your pointer to const char * to be able to store it in an SV -- without exposing anything to the Perl developer: sv_magic (sv, 0, PERL_MAGIC_ext, (const char *) pointer, 0); gtk2-perl uses this to implement opaque GObject wrappers. HTH, -Torsten