-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_newelem.c
executable file
·50 lines (46 loc) · 1.75 KB
/
list_newelem.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_newelem.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <akharrou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/22 19:19:47 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** list_newelem -- creates a new list element
**
** SYNOPSIS
** #include <../libft.h>
**
** t_list *
** list_newelem(void *item);
**
** PARAMETERS
**
** const void *item Item that will be stored
** in the item field of the
** newly created list element.
**
** DESCRIPTION
** Allocates a list element and stores the given 'item'
** in its item field.
**
** RETURN VALUES
** If successfuly returns a pointer to the newly created
** list element; otherwise returns NULL.
*/
#include "../Includes/stdlib_42.h"
#include "../Includes/list.h"
t_list *list_newelem(const void *item)
{
t_list *new_elem;
if (!(new_elem = malloc(sizeof(t_list))))
return (NULL);
new_elem->item = (void *)item;
new_elem->next = NULL;
return (new_elem);
}