From 2c97abf6747e3dcfa9095a646b567cb3fc0c9b8e Mon Sep 17 00:00:00 2001 From: Fu Weiting Date: Mon, 20 Jun 2022 15:33:59 +0800 Subject: [PATCH] Update ngx_list.c --- src/core/ngx_list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/ngx_list.c b/src/core/ngx_list.c index d0eb15930a8..aed15d9c60d 100644 --- a/src/core/ngx_list.c +++ b/src/core/ngx_list.c @@ -33,9 +33,9 @@ ngx_list_push(ngx_list_t *l) void *elt; ngx_list_part_t *last; - last = l->last; + last = l->last; // 访问最后一个链表节点 - if (last->nelts == l->nalloc) { + if (last->nelts == l->nalloc) { // 如果最后一个节点已满 /* the last part is full, allocate a new list part */ @@ -49,6 +49,7 @@ ngx_list_push(ngx_list_t *l) return NULL; } + // 更新last的指向 last->nelts = 0; last->next = NULL; @@ -56,6 +57,7 @@ ngx_list_push(ngx_list_t *l) l->last = last; } + // 返回最后一个节点的下一个元素位置 elt = (char *) last->elts + l->size * last->nelts; last->nelts++;