Ejemplo n.º 1
0
int			ftv_pushback(t_ftv *v, void const *new_data)
{
	if (v->capacity == v->size)
	{
		if (ftv_reserve(v, v->capacity == 0 ? 8 : v->capacity * 2))
			return (1);
	}
	ft_memcpy(v->data + v->size * v->element_size, new_data, v->element_size);
	v->size++;
	return (0);
}
int			ft_set_to_vector(t_ftmap const *s, t_ftvector *v
								, void (*cpy)(), void *ext)
{
	t_ftmap_node const	*node;
	t_byte				buf[v->chunk_size];

	if (ftv_reserve(v, s->size))
		return (ENOMEM);
	node = ftm_cbegin(s);
	while (node)
	{
		cpy((void*)buf, node, ext);
		ftv_push_back_unsafe(v, buf);
		node = ftm_cnext(node);
	}
	return (0);
}