Use the correct algorithm for the new defspace size.

While the result was correct, space->size >= space->size is always true and
thus grow_space would unconditionally increase the defspace's size.
This commit is contained in:
Bill Currie 2012-12-04 14:06:36 +09:00
parent d340aac2eb
commit c7b2996798

View file

@ -69,12 +69,11 @@ grow_space (defspace_t *space)
{
int size;
if (space->size >= space->size) {
size = space->size + GROW;
size -= size % GROW;
} else {
size = space->max_size + GROW;
}
if (space->size <= space->max_size)
return 1;
size = space->size + GROW;
size -= 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;