nxt_array.c (65:10688b89aa16) nxt_array.c (98:4077decf847b)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 4 unchanged lines hidden (view full) ---

13 nxt_array_t *array;
14
15 array = nxt_mp_alloc(mp, sizeof(nxt_array_t) + n * size);
16
17 if (nxt_slow_path(array == NULL)) {
18 return NULL;
19 }
20
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 4 unchanged lines hidden (view full) ---

13 nxt_array_t *array;
14
15 array = nxt_mp_alloc(mp, sizeof(nxt_array_t) + n * size);
16
17 if (nxt_slow_path(array == NULL)) {
18 return NULL;
19 }
20
21 array->elts = (char *) array + sizeof(nxt_array_t);
21 array->elts = nxt_pointer_to(array, sizeof(nxt_array_t));
22 array->nelts = 0;
23 array->size = size;
24 array->nalloc = n;
25 array->mem_pool = mp;
26
27 return array;
28}
29

--- 26 unchanged lines hidden (view full) ---

56 nxt_memcpy(p, array->elts, array->size * nalloc);
57
58 nxt_mp_free(array->mem_pool, array->elts);
59
60 array->elts = p;
61 array->nalloc = new_alloc;
62 }
63
22 array->nelts = 0;
23 array->size = size;
24 array->nalloc = n;
25 array->mem_pool = mp;
26
27 return array;
28}
29

--- 26 unchanged lines hidden (view full) ---

56 nxt_memcpy(p, array->elts, array->size * nalloc);
57
58 nxt_mp_free(array->mem_pool, array->elts);
59
60 array->elts = p;
61 array->nalloc = new_alloc;
62 }
63
64 p = (char *) array->elts + array->size * array->nelts;
64 p = nxt_pointer_to(array->elts, array->size * array->nelts);
65 array->nelts++;
66
67 return p;
68}
69
70
71void *
72nxt_array_zero_add(nxt_array_t *array)

--- 26 unchanged lines hidden ---
65 array->nelts++;
66
67 return p;
68}
69
70
71void *
72nxt_array_zero_add(nxt_array_t *array)

--- 26 unchanged lines hidden ---