pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/nbsed/files sync with src:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/287197d70d56
branches:  trunk
changeset: 476538:287197d70d56
user:      grant <grant%pkgsrc.org@localhost>
date:      Sun Jun 13 13:12:09 2004 +0000

description:
sync with src:

safer realloc, from openbsd

diffstat:

 textproc/nbsed/files/process.c |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (72 lines):

diff -r 14859658f86c -r 287197d70d56 textproc/nbsed/files/process.c
--- a/textproc/nbsed/files/process.c    Sun Jun 13 13:11:41 2004 +0000
+++ b/textproc/nbsed/files/process.c    Sun Jun 13 13:12:09 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process.c,v 1.5 2004/06/13 13:11:41 grant Exp $        */
+/*     $NetBSD: process.c,v 1.6 2004/06/13 13:12:09 grant Exp $        */
 
 /*-
  * Copyright (c) 1992 Diomidis Spinellis.
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)process.c  8.6 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: process.c,v 1.5 2004/06/13 13:11:41 grant Exp $");
+__RCSID("$NetBSD: process.c,v 1.6 2004/06/13 13:12:09 grant Exp $");
 #endif
 #endif /* not lint */
 
@@ -147,10 +147,12 @@
                                cp = cp->u.c;
                                goto redirect;
                        case 'a':
-                               if (appendx >= appendnum)
+                               if (appendx >= appendnum) {
                                        appends = xrealloc(appends,
                                            sizeof(struct s_appends) *
-                                           (appendnum *= 2));
+                                           (appendnum * 2));
+                                       appendnum *= 2;
+                               }
                                appends[appendx].type = AP_STRING;
                                appends[appendx].s = cp->t;
                                appends[appendx].len = strlen(cp->t);
@@ -239,10 +241,12 @@
                                flush_appends();
                                exit(0);
                        case 'r':
-                               if (appendx >= appendnum)
+                               if (appendx >= appendnum) {
                                        appends = xrealloc(appends,
                                            sizeof(struct s_appends) *
-                                           (appendnum *= 2));
+                                           (appendnum * 2));
+                                       appendnum *= 2;
+                               }
                                appends[appendx].type = AP_FILE;
                                appends[appendx].s = cp->t;
                                appends[appendx].len = strlen(cp->t);
@@ -594,8 +598,9 @@
 
 #define        NEEDSP(reqlen)                                                  \
        if (sp->len + (reqlen) + 1 >= sp->blen) {                       \
-               sp->blen += (reqlen) + 1024;                            \
-               sp->space = sp->back = xrealloc(sp->back, sp->blen);    \
+               size_t newlen = sp->blen + (reqlen) + 1024;             \
+               sp->space = sp->back = xrealloc(sp->back, newlen);      \
+               sp->blen = newlen;                                      \
                dst = sp->space + sp->len;                              \
        }
 
@@ -638,8 +643,9 @@
        /* Make sure SPACE has enough memory and ramp up quickly. */
        tlen = sp->len + len + 1;
        if (tlen > sp->blen) {
-               sp->blen = tlen + 1024;
-               sp->space = sp->back = xrealloc(sp->back, sp->blen);
+               size_t newlen = tlen + 1024;
+               sp->space = sp->back = xrealloc(sp->back, newlen);
+               sp->blen = newlen;
        }
 
        if (spflag == REPLACE)



Home | Main Index | Thread Index | Old Index