2004-09-03 11:50:30 -04:00
|
|
|
|
2004-09-28 04:34:51 -04:00
|
|
|
/*
|
2004-09-29 12:00:49 -04:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 04:34:51 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-09-03 11:50:30 -04:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
|
|
|
|
|
2004-09-06 14:45:00 -04:00
|
|
|
void *ngx_list_push(ngx_list_t *l)
|
2004-09-03 11:50:30 -04:00
|
|
|
{
|
|
|
|
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 */
|
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
last = ngx_palloc(l->pool, sizeof(ngx_list_part_t));
|
|
|
|
if (last == NULL) {
|
2004-09-03 11:50:30 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
last->elts = ngx_palloc(l->pool, l->nalloc * l->size);
|
|
|
|
if (last->elts == NULL) {
|
2004-09-03 11:50:30 -04:00
|
|
|
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;
|
|
|
|
}
|