comparison src/core/ngx_list.c @ 414:388a842cbbe1

nginx-0.0.10-2004-09-03-19:50:30 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 03 Sep 2004 15:50:30 +0000
parents
children b9bd635011de
comparison
equal deleted inserted replaced
413:de9d4726e28a 414:388a842cbbe1
1
2 #include <ngx_config.h>
3 #include <ngx_core.h>
4
5
6 void *ngx_push_list(ngx_list_t *l)
7 {
8 void *elt;
9 ngx_list_part_t *last;
10
11 last = l->last;
12
13 if (last->nelts == l->nalloc) {
14
15 /* the last part is full, allocate a new list part */
16
17 if (!(last = ngx_palloc(l->pool, sizeof(ngx_list_part_t)))) {
18 return NULL;
19 }
20
21 if (!(last->elts = ngx_palloc(l->pool, l->nalloc * l->size))) {
22 return NULL;
23 }
24
25 last->nelts = 0;
26 last->next = NULL;
27
28 l->last->next = last;
29 l->last = last;
30 }
31
32 elt = (char *) last->elts + l->size * last->nelts;
33 last->nelts++;
34
35 return elt;
36 }