home · contact · privacy
Use not f_name variable but __func__, standardize function name writing.
[plomrogue] / src / client / array_append.c
1 /* src/client/array_append.c */
2
3 #include "array_append.h"
4 #include <stddef.h> /* size_t */
5 #include <stdint.h> /* uint32_t */
6 #include <stdlib.h> /* free() */
7 #include <string.h> /* memcpy() */
8 #include "../common/try_malloc.h" /* try_malloc() */
9
10
11
12 extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
13                         void ** ptr_old_array)
14 {
15     uint32_t old_size = old_n * region_size;
16     uint32_t new_size = old_size + region_size;
17     char * new_array = try_malloc(new_size, __func__);
18     memcpy(new_array, * ptr_old_array, old_size);
19     memcpy(new_array + (old_n * region_size), new_region, region_size);
20     free(* ptr_old_array);
21     * ptr_old_array = new_array;
22 }
23