Source-Changes-HG archive

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

[src/trunk]: src/bin/ps do not update maxlen if realloc fails.



details:   https://anonhg.NetBSD.org/src/rev/3d2c6deeff0d
branches:  trunk
changeset: 507362:3d2c6deeff0d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Mar 20 19:05:11 2001 +0000

description:
do not update maxlen if realloc fails.

diffstat:

 bin/ps/fmt.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (36 lines):

diff -r 2cd9590b32fa -r 3d2c6deeff0d bin/ps/fmt.c
--- a/bin/ps/fmt.c      Tue Mar 20 18:49:49 2001 +0000
+++ b/bin/ps/fmt.c      Tue Mar 20 19:05:11 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fmt.c,v 1.14 1999/12/03 02:26:36 simonb Exp $  */
+/*     $NetBSD: fmt.c,v 1.15 2001/03/20 19:05:11 itojun Exp $  */
 
 #include <kvm.h>
 #include <stdio.h>
@@ -17,20 +17,21 @@
 {
        static char *v = 0, *nv;
        static int maxlen = 0;
-       int len;
+       int len, nlen;
 
        if (*leftp == 0)
                return;
        len = strlen(s) * 4 + 1;
        if (len > maxlen) {
                if (maxlen == 0)
-                       maxlen = getpagesize();
-               while (len > maxlen)
-                       maxlen *= 2;
-               nv = realloc(v, maxlen);
+                       nlen = getpagesize();
+               while (len > nlen)
+                       nlen *= 2;
+               nv = realloc(v, nlen);
                if (nv == 0)
                        return;
                v = nv;
+               maxlen = nlen;
        }
        strvis(v, s, VIS_TAB | VIS_NL | VIS_CSTYLE);
        if (*leftp != -1) {



Home | Main Index | Thread Index | Old Index