Merge branch 'weliu-master'
This commit is contained in:
commit
afdd51ff15
|
@ -227,22 +227,17 @@ 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 in_len, size_t buf_len, nghttp2_mem *mem) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
nghttp2_buf_chain *cur_chain;
|
nghttp2_buf_chain *cur_chain;
|
||||||
nghttp2_buf_chain *head_chain = NULL;
|
nghttp2_buf_chain *head_chain;
|
||||||
nghttp2_buf_chain **dst_chain = &head_chain;
|
nghttp2_buf_chain **dst_chain = &head_chain;
|
||||||
|
|
||||||
for (i = 0; i < in_len; ++i) {
|
head_chain = nghttp2_mem_malloc(mem, sizeof(nghttp2_buf_chain) * in_len);
|
||||||
uint8_t *begin = bufs_in[i];
|
if (head_chain == NULL) {
|
||||||
|
|
||||||
cur_chain = nghttp2_mem_malloc(mem, sizeof(nghttp2_buf_chain));
|
|
||||||
if (cur_chain == NULL) {
|
|
||||||
while (head_chain) {
|
|
||||||
nghttp2_buf_chain *tmp_chain = head_chain->next;
|
|
||||||
nghttp2_mem_free(mem, head_chain);
|
|
||||||
head_chain = tmp_chain;
|
|
||||||
}
|
|
||||||
return NGHTTP2_ERR_NOMEM;
|
return NGHTTP2_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < in_len; ++i) {
|
||||||
|
uint8_t *begin = bufs_in[i];
|
||||||
|
cur_chain = &head_chain[i];
|
||||||
cur_chain->next = NULL;
|
cur_chain->next = NULL;
|
||||||
nghttp2_buf_wrap_init(&cur_chain->buf, begin, buf_len);
|
nghttp2_buf_wrap_init(&cur_chain->buf, begin, buf_len);
|
||||||
|
|
||||||
|
@ -269,10 +264,9 @@ void nghttp2_bufs_wrap_free(nghttp2_bufs *bufs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (bufs->head) {
|
if (bufs->head) {
|
||||||
nghttp2_buf_chain *tmp_chain = bufs->head->next;
|
|
||||||
nghttp2_mem_free(bufs->mem, bufs->head);
|
nghttp2_mem_free(bufs->mem, bufs->head);
|
||||||
bufs->head = tmp_chain;
|
bufs->head = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue