-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathn_array_clone.c
More file actions
35 lines (28 loc) · 752 Bytes
/
Copy pathn_array_clone.c
File metadata and controls
35 lines (28 loc) · 752 Bytes
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
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "n_array_int.h"
tn_array *n_array_clone_ex(const tn_array *arr, t_fn_dup dup_fn)
{
tn_array *dupl;
dupl = n_array_new(arr->allocated, arr->free_fn, arr->cmp_fn);
dupl->flags = arr->flags;
if (dup_fn != NULL) {
register unsigned int i;
int n = arr->start_index;
for (i = 0; i < arr->items; i++)
n_array_push(dupl, dup_fn(arr->data[n + i]));
n_assert(dupl->items == arr->items);
}
return dupl;
}
/* legacy */
tn_array *n_array_clone(const tn_array *arr)
{
return n_array_clone_ex(arr, NULL);
}
/* legacy */
tn_array *n_array_dup(const tn_array *arr, t_fn_dup dup_fn)
{
return n_array_clone_ex(arr, dup_fn);
}