|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: adjusting the length of an SV?
|
> On Tue, Jun 12, 2001 at 02:40:15PM -0400, Kyle R . Burton wrote:
> > > Without actualy using something like sv_setpv, sv_setpvn, or sv_setsv,
> > > can I just null out one of the chars, and then adjust the length that
> > > Perl has assoicated with the SV?
> > >
> > > I can't seem to find any macros or functions in perlguts or perlxs that
> > > shows how to adjust this length.
> >
> > Sorry, I found it in perlguts:
> >
> > SvCUR_set(SV*,I32)
>
>
> Note that you should not null out characters - Perl has 8-bit clean strings,
> and a null is a valid character.
In this case you are mistaken. According to perlguts:
All SVs that contain strings should be terminated with a NUL
character. If it is not NUL-terminated there is a risk of core
dumps and corruptions from code which passes the string to C
functions or system calls which expect a NUL-terminated string.
Perl's own functions typically add a trailing NUL for this
reason.
Since Kyle is shortening the string with SvCUR_set, he should insert a
NUL character after the new final character of the string.
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|