Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
488c3588
Commit
488c3588
authored
Aug 17, 2016
by
Wenfeng Liu
Committed by
Tatsuhiro Tsujikawa
Aug 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: Malloc nghttp2_buf_chain array once in nghttp2_bufs_wrap_init2()
to simplify logic
parent
4f02b191
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
15 deletions
+9
-15
lib/nghttp2_buf.c
lib/nghttp2_buf.c
+9
-15
No files found.
lib/nghttp2_buf.c
View file @
488c3588
...
...
@@ -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
i
=
0
;
nghttp2_buf_chain
*
cur_chain
;
nghttp2_buf_chain
*
head_chain
=
NULL
;
nghttp2_buf_chain
*
head_chain
;
nghttp2_buf_chain
**
dst_chain
=
&
head_chain
;
head_chain
=
nghttp2_mem_malloc
(
mem
,
sizeof
(
nghttp2_buf_chain
)
*
in_len
);
if
(
head_chain
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
for
(
i
=
0
;
i
<
in_len
;
++
i
)
{
uint8_t
*
begin
=
bufs_in
[
i
];
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
;
}
cur_chain
=
&
head_chain
[
i
];
cur_chain
->
next
=
NULL
;
nghttp2_buf_wrap_init
(
&
cur_chain
->
buf
,
begin
,
buf_len
);
...
...
@@ -269,10 +264,9 @@ void nghttp2_bufs_wrap_free(nghttp2_bufs *bufs) {
return
;
}
while
(
bufs
->
head
)
{
nghttp2_buf_chain
*
tmp_chain
=
bufs
->
head
->
next
;
if
(
bufs
->
head
)
{
nghttp2_mem_free
(
bufs
->
mem
,
bufs
->
head
);
bufs
->
head
=
tmp_chain
;
bufs
->
head
=
NULL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment