summaryrefslogtreecommitdiff
path: root/lib/libcurses/comp_expand.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses/comp_expand.c')
-rw-r--r--lib/libcurses/comp_expand.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/libcurses/comp_expand.c b/lib/libcurses/comp_expand.c
index 286326d56e4..089162f149d 100644
--- a/lib/libcurses/comp_expand.c
+++ b/lib/libcurses/comp_expand.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: comp_expand.c,v 1.2 1998/08/14 21:11:38 millert Exp $ */
+/* $OpenBSD: comp_expand.c,v 1.3 1998/08/15 18:44:43 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -63,17 +63,16 @@ bool islong = (strlen(str) > 3);
size_t need = (2 + strlen(str)) * 4;
int ch;
- if (buffer == 0) {
- nbuffer = malloc(length = need);
- } else if (need > length) {
- nbuffer = realloc(buffer, length = need);
- }
- if (nbuffer == 0) {
- if (buffer != 0)
- free(buffer);
- return(NULL);
+ if (buffer == 0 || need > length) {
+ length = need;
+ nbuffer = buffer ? realloc(buffer, length) : malloc(length);
+ if (nbuffer == 0) {
+ if (buffer != 0)
+ free(buffer);
+ return(NULL);
+ }
+ buffer = nbuffer;
}
- buffer = nbuffer;
bufp = 0;
ptr = str;