data_structures
list_new.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* list_new.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/16 22:46:20 by unite #+# #+# */
10 /* Updated: 2020/09/07 22:01:23 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "list.h"
15 
16 t_list *list_new(const t_type *type)
17 {
18  t_list *list;
19 
20  list = ds_xcalloc(sizeof(t_list), 1);
21  list->type = type;
22  return (list);
23 }
ds_xcalloc
void * ds_xcalloc(size_t count, size_t size)
Replicates behaviour of calloc from libc, but fails on memory allocation errors.
Definition: ds_xcalloc.c:22
s_list
Doubly-linked list of generic items.
Definition: list.h:54
s_type
A full representation of a data type, used to achieve polymorphism in the implementation of data stru...
Definition: types.h:47
s_list::type
const t_type * type
The type of items in this list.
Definition: list.h:59
list.h
list_new
t_list * list_new(const t_type *type)
Allocates memory and initializes an empty list.
Definition: list_new.c:16