Commit 8acef271 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Use pointer-to-pointer idiom to construct linked list

parent c6111b37
......@@ -227,8 +227,8 @@ int nghttp2_bufs_wrap_init2(nghttp2_bufs *bufs, uint8_t *const *bufs_in,
size_t in_len, size_t buf_len, nghttp2_mem *mem) {
size_t i = 0;
nghttp2_buf_chain *cur_chain;
nghttp2_buf_chain *pre_chain = NULL;
nghttp2_buf_chain *head_chain = NULL;
nghttp2_buf_chain **dst_chain = &head_chain;
for (i = 0; i < in_len; ++i) {
uint8_t *begin = bufs_in[i];
......@@ -246,13 +246,8 @@ int nghttp2_bufs_wrap_init2(nghttp2_bufs *bufs, uint8_t *const *bufs_in,
cur_chain->next = NULL;
nghttp2_buf_wrap_init(&cur_chain->buf, begin, buf_len);
if (pre_chain) {
pre_chain->next = cur_chain;
} else {
head_chain = cur_chain;
}
pre_chain = cur_chain;
*dst_chain = cur_chain;
dst_chain = &cur_chain->next;
}
bufs->mem = mem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment