blob: 885f8f508a595d1d53221239d41fefbe162b20d8 (
plain)
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
35
36
|
#include <ngx_config.h>
#include <ngx_core.h>
void *ngx_list_push(ngx_list_t *l)
{
void *elt;
ngx_list_part_t *last;
last = l->last;
if (last->nelts == l->nalloc) {
/* the last part is full, allocate a new list part */
if (!(last = ngx_palloc(l->pool, sizeof(ngx_list_part_t)))) {
return NULL;
}
if (!(last->elts = ngx_palloc(l->pool, l->nalloc * l->size))) {
return NULL;
}
last->nelts = 0;
last->next = NULL;
l->last->next = last;
l->last = last;
}
elt = (char *) last->elts + l->size * last->nelts;
last->nelts++;
return elt;
}
|