From 1246fd9e30fb3c340820980cdf7fe9a183f9b500 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 7 Mar 2011 13:36:00 +0900 Subject: [PATCH] Use the correct size when growing a data space. --- tools/qfcc/source/defspace.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/defspace.c b/tools/qfcc/source/defspace.c index ab7289243..053124e01 100644 --- a/tools/qfcc/source/defspace.c +++ b/tools/qfcc/source/defspace.c @@ -70,7 +70,14 @@ static locref_t *free_locrefs; static int grow_space (defspace_t *space) { - int size = space->max_size + GROW; + int size; + + if (space->size >= space->size) { + size = space->size + GROW; + size -= size % GROW; + } else { + size = space->max_size + GROW; + } space->data = realloc (space->data, size * sizeof (pr_type_t)); memset (space->data + space->max_size, 0, GROW * sizeof (pr_type_t)); space->max_size = size;