summaryrefslogtreecommitdiff
path: root/usr.bin/dc/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/dc/stack.c')
-rw-r--r--usr.bin/dc/stack.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c
index 5dd9e8e4194..c35fb6a7fbb 100644
--- a/usr.bin/dc/stack.c
+++ b/usr.bin/dc/stack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stack.c,v 1.2 2003/09/19 19:00:36 deraadt Exp $ */
+/* $OpenBSD: stack.c,v 1.3 2003/09/28 19:29:33 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: stack.c,v 1.2 2003/09/19 19:00:36 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: stack.c,v 1.3 2003/09/28 19:29:33 otto Exp $";
#endif /* not lint */
#include <err.h>
@@ -119,15 +119,15 @@ stack_dup(struct stack *stack)
static void
stack_grow(struct stack *stack)
{
- int old_size, i;
+ int new_size, i;
if (++stack->sp == stack->size) {
- old_size = stack->size;
- stack->size *= 2;
+ new_size = stack->size * 2 + 1;
stack->stack = brealloc(stack->stack,
- ++stack->size * sizeof(*stack->stack));
- for (i = old_size; i < stack->size; i++)
+ new_size * sizeof(*stack->stack));
+ for (i = stack->size; i < new_size; i++)
stack->stack[i].array = NULL;
+ stack->size = new_size;
}
}