tfoertsch has asked for the wisdom of the Perl Monks concerning the following question:
I have a bunch of C-strings with or without a trailing \0. I want to make them available in Perl as read-only variables. When the perl SV is destroyed the string must not be freed obviously.
Do I need to make those variables magic? Or is there a simpler way?
If I need magic, do I need to implement all of the 8 MGVTBL members? What if some of them are NULL?
I think I need only an svt_free function that does:
SvPVX(var) = NULL; SvCUR(var) = 0;
Is this correct?
I have read somewhere that perl strings do not need the trailing \0 byte. But for some reasons it is normally allocated. Why? Is it necessary? What can happen if there is no trailing \0?
Thanks,
Torsten
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: readonly access to C-level strings
by ambrus (Abbot) on Jul 02, 2009 at 11:01 UTC | |
by tfoertsch (Beadle) on Jul 02, 2009 at 12:47 UTC | |
|
Re: readonly access to C-level strings
by jettero (Monsignor) on Jul 02, 2009 at 11:05 UTC | |
by tfoertsch (Beadle) on Jul 02, 2009 at 12:33 UTC | |
by ikegami (Patriarch) on Jul 02, 2009 at 16:20 UTC | |
|
Re: readonly access to C-level strings
by Anonymous Monk on Jul 02, 2009 at 11:24 UTC | |
|
[SOLUTION] readonly access to C-level strings
by tfoertsch (Beadle) on Jul 03, 2009 at 07:29 UTC | |
by Anonymous Monk on Jul 03, 2009 at 07:51 UTC | |
by roboticus (Chancellor) on Jul 03, 2009 at 11:42 UTC |