Use the correct size when growing a data space.

This commit is contained in:
Bill Currie 2011-03-07 13:36:00 +09:00
parent 02a70ebe1c
commit 1246fd9e30

View file

@ -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;