diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-08-15 19:06:39 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-08-15 19:06:39 +0000 |
commit | eff1ef758b0ad22d72d2d0e6691e0dcf09870f56 (patch) | |
tree | 27184a5d40572d7e67fb966ffe6dc59eef81be77 /lib/libcurses | |
parent | 48794a3cba64d810b2e5ce122ccb0bc9fea78a10 (diff) |
simplify a few things wrt realloc
Diffstat (limited to 'lib/libcurses')
-rw-r--r-- | lib/libcurses/lib_tparm.c | 7 | ||||
-rw-r--r-- | lib/libcurses/safe_sprintf.c | 7 |
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/libcurses/lib_tparm.c b/lib/libcurses/lib_tparm.c index 672ae532e46..beedb78d748 100644 --- a/lib/libcurses/lib_tparm.c +++ b/lib/libcurses/lib_tparm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tparm.c,v 1.2 1998/08/14 21:11:40 millert Exp $ */ +/* $OpenBSD: lib_tparm.c,v 1.3 1998/08/15 19:06:36 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -306,13 +306,12 @@ static int static_vars[NUM_VARS]; len_fmt = (cp - string) + len_fmt + 2; nformat = format ? realloc(format, len_fmt) : malloc(len_fmt); - if (nformat != 0) { - format = nformat; - } else { + if (nformat == 0) { if (format != 0) free(format); return 0; } + format = nformat; } if (number > 9) number = 9; diff --git a/lib/libcurses/safe_sprintf.c b/lib/libcurses/safe_sprintf.c index 01f98d470cd..397ede9c605 100644 --- a/lib/libcurses/safe_sprintf.c +++ b/lib/libcurses/safe_sprintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safe_sprintf.c,v 1.3 1998/08/14 21:11:42 millert Exp $ */ +/* $OpenBSD: safe_sprintf.c,v 1.4 1998/08/15 19:06:38 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -232,10 +232,7 @@ _nc_printf_string(const char *fmt, va_list ap) if (screen_lines > rows) rows = screen_lines; if (screen_columns > cols) cols = screen_columns; len = (rows * (cols + 1)) + 1; - if (buf == 0) - nbuf = malloc(len); - else - nbuf = realloc(buf, len); + nbuf = buf ? realloc(buf, len) : malloc(len); if (nbuf == NULL) { if (buf != NULL) free(buf); |