data_structures
array_append.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* array_append.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/16 23:27:51 by unite #+# #+# */
10 /* Updated: 2020/09/07 19:53:27 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "array.h"
15 #include "array_utils.h"
16 
17 void array_append(t_array *array, const void *content)
18 {
19  if (array->size == array->capacity)
20  array_grow(array);
21  array->arr[array->size] = array->type->copy(content);
22  array->size++;
23 }
s_type::copy
void *(* copy)(const void *)
A function pointer used to copy the data type.
Definition: types.h:50
array.h
s_array::type
const t_type * type
The type of items in this array.
Definition: array.h:52
s_array::arr
void ** arr
The data.
Definition: array.h:51
s_array
A resizable array.
Definition: array.h:47
s_array::capacity
size_t capacity
The capacity of this array.
Definition: array.h:50
s_array::size
size_t size
The number of items in this array.
Definition: array.h:49
array_append
void array_append(t_array *array, const void *content)
Appends a copy the specified element to the end of this array.
Definition: array_append.c:17
array_utils.h