Exemple #1
0
static int resize_line(struct line *line, unsigned int width)
{
	struct cell *tmp;
	int ret;

	if (!line)
		return -EINVAL;

	if (!width)
		width = DEFAULT_WIDTH;

	if (line->size < width) {
		tmp = realloc(line->cells, width * sizeof(struct cell));
		if (!tmp)
			return -ENOMEM;

		line->cells = tmp;

		while (line->size < width) {
			ret = init_cell(&line->cells[line->size]);
			if (ret)
				return ret;
			line->size++;
		}
	} else if (line->size > width) {
		while (line->size > width) {
			line->size--;
			destroy_cell(&line->cells[line->size]);
		}
	}

	return 0;
}
Exemple #2
0
void remove_beggin_listD(listD l){
	if(empty_listD(l))
		return;

	cell saveC= l->first;
	l->first= l->first->next;
	if(l->first->next != NULL)
		l->first->prec= NULL;
	else
		l->last= NULL;
	destroy_cell(saveC);
}
Exemple #3
0
static void free_line(struct line *line)
{
	unsigned int i;

	if (!line)
		return;

	for (i = 0; i < line->size; ++i)
		destroy_cell(&line->cells[i]);

	free(line->cells);
	free(line);
}
Exemple #4
0
void remove_end_listD(listD l){
	if(empty_listD(l))
		return;

	cell saveC= l->last;
	if(l->last->prec != NULL)
		l->last->prec->next= NULL;
	else
		l->first= NULL;
	l->last= l->last->prec;

	if(saveC == l->curs)
		move_end_listD(l);			// si le curseur etait sur le dernier
	destroy_cell(saveC);
}
Exemple #5
0
void remove_listD(listD l){
	if(curs_fist_listD(l)){
		remove_beggin_listD(l);
		return;
	}
	if(curs_last_listD(l)){
		remove_end_listD(l);
		return;
	}

	cell saveC= l->curs;
	l->curs->prec->next= l->curs->next;
	l->curs->next->prec= l->curs->prec;
	move_next_listD(l);

	destroy_cell(saveC);
}