-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_ldcd_cellnew.c
executable file
·43 lines (40 loc) · 1.48 KB
/
ft_ldcd_cellnew.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ldcd_cellnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/12/04 01:23:50 by tseguier #+# #+# */
/* Updated: 2014/07/06 14:19:11 by tseguier ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
#include "ft_ldcd_cell.h"
t_ldcd_cell ft_ldcd_cellnew(void *elem, size_t elem_size)
{
t_ldcd_cell newcell;
newcell = (t_ldcd_cell)malloc(sizeof(struct s_ldcd_cell));
if (!newcell)
return (NULL);
if (!elem || elem_size == 0)
{
newcell->content = elem;
newcell->content_size = 0;
}
else
{
newcell->content = ft_memalloc(elem_size);
if (!newcell->content)
{
ft_memdel((void **)&newcell);
return (NULL);
}
ft_bzero(newcell->content, elem_size);
newcell->content_size = elem_size;
newcell->next = NULL;
newcell->prev = NULL;
}
return (newcell);
}