Call realloc() less often because it is potentially slow.