nxt_list.c (0:a63ceefd6ab0) nxt_list.c (65:10688b89aa16)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8
9
10nxt_list_t *
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8
9
10nxt_list_t *
11nxt_list_create(nxt_mem_pool_t *mp, nxt_uint_t n, size_t size)
11nxt_list_create(nxt_mp_t *mp, nxt_uint_t n, size_t size)
12{
13 nxt_list_t *list;
14
12{
13 nxt_list_t *list;
14
15 list = nxt_mem_alloc(mp, sizeof(nxt_list_t) + n * size);
15 list = nxt_mp_get(mp, sizeof(nxt_list_t) + n * size);
16
17 if (nxt_fast_path(list != NULL)) {
18 list->last = &list->part;
19 list->size = size;
20 list->nalloc = n;
21 list->mem_pool = mp;
22 list->part.next = NULL;
23 list->part.nelts = 0;

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

34 nxt_list_part_t *last;
35
36 last = list->last;
37
38 if (last->nelts == list->nalloc) {
39
40 /* The last list part is filled up, allocating a new list part. */
41
16
17 if (nxt_fast_path(list != NULL)) {
18 list->last = &list->part;
19 list->size = size;
20 list->nalloc = n;
21 list->mem_pool = mp;
22 list->part.next = NULL;
23 list->part.nelts = 0;

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

34 nxt_list_part_t *last;
35
36 last = list->last;
37
38 if (last->nelts == list->nalloc) {
39
40 /* The last list part is filled up, allocating a new list part. */
41
42 last = nxt_mem_alloc(list->mem_pool,
43 sizeof(nxt_list_part_t) + list->nalloc * list->size);
42 last = nxt_mp_get(list->mem_pool,
43 sizeof(nxt_list_part_t) + list->nalloc * list->size);
44
45 if (nxt_slow_path(last == NULL)) {
46 return NULL;
47 }
48
49 last->next = NULL;
50 last->nelts = 0;
51

--- 57 unchanged lines hidden ---
44
45 if (nxt_slow_path(last == NULL)) {
46 return NULL;
47 }
48
49 last->next = NULL;
50 last->nelts = 0;
51

--- 57 unchanged lines hidden ---