-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector_delete.c
29 lines (27 loc) · 1.18 KB
/
vector_delete.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* :::::::: */
/* vector_delete.c :+: :+: */
/* +:+ */
/* By: abobas <abobas@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/05/16 00:45:23 by abobas #+# #+# */
/* Updated: 2020/05/28 20:50:43 by abobas ######## odam.nl */
/* */
/* ************************************************************************** */
#include "includes/libft.h"
#include <stdlib.h>
void vector_delete(t_vector *v, int index)
{
if (index < 0 || index >= v->total)
return ;
if (v->data[index])
free(v->data[index]);
while (index < v->total - 1)
{
v->data[index] = v->data[index + 1];
v->data[index + 1] = 0;
index++;
}
v->total--;
}