-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_extendleft.c
executable file
·58 lines (55 loc) · 2.04 KB
/
list_extendleft.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_extendleft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/22 19:25:33 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** list_extendleft -- prepends multiple new elements to a list.
**
** SYNOPSIS
** #include <../libft.h>
**
** int
** list_extendleft(t_list **head, const void **item_vector);
**
** PARAMETERS
**
** t_list **head Pointer to a pointer to the
** first element of a list.
**
** const void **item_vector Vector containing items
** to add to the end of the
** list.
**
** DESCRIPTION
** Creates new list elements using the items in the item
** vector and adds the newly created list elements to the
** beginning of the list (that (*head) points to).
**
** (*head) is made to point to the first element of the list.
**
** RETURN VALUES
** Returns 0 if successful; otherwise -1.
*/
#include "../Includes/list.h"
int list_extendleft(t_list **head, const void **item_vector)
{
if (head && item_vector)
{
while (*item_vector)
{
if ((list_prepend(head, *item_vector)) == -1)
return (-1);
item_vector++;
}
return (0);
}
return (-1);
}