Change 30000 by [EMAIL PROTECTED] on 2007/01/26 11:18:02

        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.

Affected files ...

... //depot/perl/gv.c#350 edit
... //depot/perl/toke.c#741 edit

Differences ...

==== //depot/perl/gv.c#350 (text) ====
Index: perl/gv.c
--- perl/gv.c#349~29987~        2007-01-25 15:18:25.000000000 -0800
+++ perl/gv.c   2007-01-26 03:18:02.000000000 -0800
@@ -113,22 +113,22 @@
     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 @@
     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 @@
                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);

==== //depot/perl/toke.c#741 (text) ====
Index: perl/toke.c
--- perl/toke.c#740~29987~      2007-01-25 15:18:25.000000000 -0800
+++ perl/toke.c 2007-01-26 03:18:02.000000000 -0800
@@ -794,11 +794,11 @@
            char *tmpbuf, *tmpbuf2;
            GV **gvp, *gv2;
            STRLEN tmplen2 = strlen(s);
-           if (tmplen + 2 < sizeof smallbuf)
+           if (tmplen + 2 <= sizeof smallbuf)
                tmpbuf = smallbuf;
            else
                Newx(tmpbuf, tmplen + 2, char);
-           if (tmplen2 + 2 < sizeof smallbuf2)
+           if (tmplen2 + 2 <= sizeof smallbuf2)
                tmpbuf2 = smallbuf2;
            else
                Newx(tmpbuf2, tmplen2 + 2, char);
End of Patch.

Reply via email to