diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-01-26 11:18:02 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-01-26 11:18:02 +0000 |
commit | 798b63bc924a07589315b3229311582adce06136 (patch) | |
tree | a51d217cad534c72b181b97179e2543a2ed89327 /gv.c | |
parent | ef36c6a75a14ecb6dcb87636f28264674a031e0b (diff) | |
download | perl-798b63bc924a07589315b3229311582adce06136.tar.gz |
As we're not passing over (or copying in) a NUL, don't need that extra
byte for it, so correct the < to <= so that we use the smallbuf
whenever possible.
p4raw-id: //depot/perl@30000
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -113,22 +113,22 @@ Perl_gv_fetchfile(pTHX_ const char *name) if (!PL_defstash) return NULL; - tmplen = strlen(name) + 2; - if (tmplen < sizeof smallbuf) + tmplen = strlen(name); + if (tmplen + 2 <= sizeof smallbuf) tmpbuf = smallbuf; else - Newx(tmpbuf, tmplen + 1, char); + Newx(tmpbuf, tmplen, char); /* This is where the debugger's %{"::_<$filename"} hash is created */ tmpbuf[0] = '_'; tmpbuf[1] = '<'; - memcpy(tmpbuf + 2, name, tmplen - 1); - gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, TRUE); + memcpy(tmpbuf + 2, name, tmplen); + gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen + 2, TRUE); if (!isGV(gv)) { - gv_init(gv, PL_defstash, tmpbuf, tmplen, FALSE); + gv_init(gv, PL_defstash, tmpbuf, tmplen + 2, FALSE); #ifdef PERL_DONT_CREATE_GVSV - GvSV(gv) = newSVpvn(name, tmplen - 2); + GvSV(gv) = newSVpvn(name, tmplen); #else - sv_setpvn(GvSV(gv), name, tmplen - 2); + sv_setpvn(GvSV(gv), name, tmplen); #endif if (PERLDB_LINE) hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile); @@ -742,7 +742,7 @@ Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) HV *stash; GV *tmpgv; - if (namelen + 2 < sizeof smallbuf) + if (namelen + 2 <= sizeof smallbuf) tmpbuf = smallbuf; else Newx(tmpbuf, namelen + 2, char); @@ -834,7 +834,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, char smallbuf[128]; char *tmpbuf; - if (len + 2 < (I32)sizeof (smallbuf)) + if (len + 2 <= (I32)sizeof (smallbuf)) tmpbuf = smallbuf; else Newx(tmpbuf, len+2, char); |