/* highs, and targets are managed as dynamic arrays during a table load.  */
static int alloc_targets(struct dm_table *t, unsigned int num)
/* highs, and targets are managed as dynamic arrays during a table load.  */
static int alloc_targets(struct dm_table *t, unsigned int num)
{
	sector_t *n_highs;
	struct dm_target *n_targets;
	int n = t->num_targets;
	n_highs = (sector_t *) dm_vcalloc(num + 1, sizeof(struct dm_target) +
					  sizeof(sector_t));
	if (!n_highs)
		return -ENOMEM;
	n_targets = (struct dm_target *) (n_highs + num);
	if (n) {
		memcpy(n_highs, t->highs, sizeof(*n_highs) * n);
		memcpy(n_targets, t->targets, sizeof(*n_targets) * n);
	}
	memset(n_highs + n, -1, sizeof(*n_highs) * (num - n));
	vfree(t->highs);
	t->num_allocated = num;
	t->highs = n_highs;
	t->targets = n_targets;
	return 0;
}