Skip to content

Commit

Permalink
Update ngx_list.c
Browse files Browse the repository at this point in the history
  • Loading branch information
LLHFWT authored Jun 20, 2022
1 parent 6030c68 commit 2c97abf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/ngx_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -49,13 +49,15 @@ ngx_list_push(ngx_list_t *l)
return NULL;
}

// 更新last的指向
last->nelts = 0;
last->next = NULL;

l->last->next = last;
l->last = last;
}

// 返回最后一个节点的下一个元素位置
elt = (char *) last->elts + l->size * last->nelts;
last->nelts++;

Expand Down

0 comments on commit 2c97abf

Please sign in to comment.