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
aefc0d1e
Commit
aefc0d1e
authored
Mar 13, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use calloc instead of malloc + memset; remove useless memset
parent
1be8d1b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
22 deletions
+14
-22
lib/nghttp2_frame.c
lib/nghttp2_frame.c
+8
-11
lib/nghttp2_map.c
lib/nghttp2_map.c
+5
-4
lib/nghttp2_session.c
lib/nghttp2_session.c
+1
-7
No files found.
lib/nghttp2_frame.c
View file @
aefc0d1e
...
...
@@ -67,12 +67,12 @@ void nghttp2_frame_headers_init(nghttp2_headers *frame,
uint8_t
flags
,
int32_t
stream_id
,
int32_t
pri
,
nghttp2_nv
*
nva
,
size_t
nvlen
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_headers
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
0
,
NGHTTP2_HEADERS
,
flags
,
stream_id
);
frame
->
p
ri
=
pri
;
frame
->
p
adlen
=
0
;
frame
->
nva
=
nva
;
frame
->
nvlen
=
nvlen
;
frame
->
cat
=
NGHTTP2_HCAT_REQUEST
;
frame
->
pri
=
pri
;
}
void
nghttp2_frame_headers_free
(
nghttp2_headers
*
frame
)
...
...
@@ -83,7 +83,6 @@ void nghttp2_frame_headers_free(nghttp2_headers *frame)
void
nghttp2_frame_priority_init
(
nghttp2_priority
*
frame
,
int32_t
stream_id
,
int32_t
pri
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_priority
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
4
,
NGHTTP2_PRIORITY
,
NGHTTP2_FLAG_NONE
,
stream_id
);
frame
->
pri
=
pri
;
...
...
@@ -96,7 +95,6 @@ void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame,
int32_t
stream_id
,
nghttp2_error_code
error_code
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_rst_stream
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
4
,
NGHTTP2_RST_STREAM
,
NGHTTP2_FLAG_NONE
,
stream_id
);
frame
->
error_code
=
error_code
;
...
...
@@ -109,7 +107,6 @@ void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame)
void
nghttp2_frame_settings_init
(
nghttp2_settings
*
frame
,
uint8_t
flags
,
nghttp2_settings_entry
*
iv
,
size_t
niv
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_settings
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
niv
*
NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH
,
NGHTTP2_SETTINGS
,
flags
,
0
);
frame
->
niv
=
niv
;
...
...
@@ -126,11 +123,11 @@ void nghttp2_frame_push_promise_init(nghttp2_push_promise *frame,
int32_t
promised_stream_id
,
nghttp2_nv
*
nva
,
size_t
nvlen
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_push_promise
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
0
,
NGHTTP2_PUSH_PROMISE
,
flags
,
stream_id
);
frame
->
p
romised_stream_id
=
promised_stream_id
;
frame
->
p
adlen
=
0
;
frame
->
nva
=
nva
;
frame
->
nvlen
=
nvlen
;
frame
->
promised_stream_id
=
promised_stream_id
;
}
void
nghttp2_frame_push_promise_free
(
nghttp2_push_promise
*
frame
)
...
...
@@ -141,10 +138,11 @@ void nghttp2_frame_push_promise_free(nghttp2_push_promise *frame)
void
nghttp2_frame_ping_init
(
nghttp2_ping
*
frame
,
uint8_t
flags
,
const
uint8_t
*
opaque_data
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_ping
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
8
,
NGHTTP2_PING
,
flags
,
0
);
if
(
opaque_data
)
{
memcpy
(
frame
->
opaque_data
,
opaque_data
,
sizeof
(
frame
->
opaque_data
));
}
else
{
memset
(
frame
->
opaque_data
,
0
,
sizeof
(
frame
->
opaque_data
));
}
}
...
...
@@ -155,7 +153,6 @@ void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
nghttp2_error_code
error_code
,
uint8_t
*
opaque_data
,
size_t
opaque_data_len
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_goaway
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
8
+
opaque_data_len
,
NGHTTP2_GOAWAY
,
NGHTTP2_FLAG_NONE
,
0
);
frame
->
last_stream_id
=
last_stream_id
;
...
...
@@ -174,7 +171,6 @@ void nghttp2_frame_window_update_init(nghttp2_window_update *frame,
int32_t
stream_id
,
int32_t
window_size_increment
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_window_update
));
nghttp2_frame_set_hd
(
&
frame
->
hd
,
4
,
NGHTTP2_WINDOW_UPDATE
,
flags
,
stream_id
);
frame
->
window_size_increment
=
window_size_increment
;
}
...
...
@@ -206,10 +202,11 @@ void nghttp2_frame_private_data_init(nghttp2_private_data *frame,
int32_t
stream_id
,
const
nghttp2_data_provider
*
data_prd
)
{
memset
(
frame
,
0
,
sizeof
(
nghttp2_private_data
));
/* At this moment, the length of DATA frame is unknown */
nghttp2_frame_set_hd
(
&
frame
->
hd
,
0
,
NGHTTP2_DATA
,
flags
,
stream_id
);
frame
->
data_prd
=
*
data_prd
;
frame
->
padlen
=
0
;
frame
->
eof
=
0
;
}
void
nghttp2_frame_private_data_free
(
nghttp2_private_data
*
frame
)
...
...
lib/nghttp2_map.c
View file @
aefc0d1e
...
...
@@ -31,12 +31,13 @@
int
nghttp2_map_init
(
nghttp2_map
*
map
)
{
map
->
tablelen
=
INITIAL_TABLE_LENGTH
;
map
->
table
=
malloc
(
sizeof
(
nghttp2_map_entry
*
)
*
map
->
tablelen
);
map
->
table
=
calloc
(
map
->
tablelen
,
sizeof
(
nghttp2_map_entry
*
)
);
if
(
map
->
table
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
memset
(
map
->
table
,
0
,
sizeof
(
nghttp2_map_entry
*
)
*
map
->
tablelen
);
map
->
size
=
0
;
return
0
;
}
...
...
@@ -118,11 +119,11 @@ static int resize(nghttp2_map *map, size_t new_tablelen)
{
size_t
i
;
nghttp2_map_entry
**
new_table
;
new_table
=
malloc
(
sizeof
(
nghttp2_map_entry
*
)
*
new_tablelen
);
new_table
=
calloc
(
new_tablelen
,
sizeof
(
nghttp2_map_entry
*
)
);
if
(
new_table
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
memset
(
new_table
,
0
,
sizeof
(
nghttp2_map_entry
*
)
*
new_tablelen
);
for
(
i
=
0
;
i
<
map
->
tablelen
;
++
i
)
{
nghttp2_map_entry
*
entry
;
for
(
entry
=
map
->
table
[
i
];
entry
;)
{
...
...
lib/nghttp2_session.c
View file @
aefc0d1e
...
...
@@ -229,12 +229,11 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
{
int
rv
;
*
session_ptr
=
malloc
(
sizeof
(
nghttp2_session
));
*
session_ptr
=
calloc
(
1
,
sizeof
(
nghttp2_session
));
if
(
*
session_ptr
==
NULL
)
{
rv
=
NGHTTP2_ERR_NOMEM
;
goto
fail_session
;
}
memset
(
*
session_ptr
,
0
,
sizeof
(
nghttp2_session
));
/* next_stream_id is initialized in either
nghttp2_session_client_new2 or nghttp2_session_server_new2 */
...
...
@@ -302,11 +301,6 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
nghttp2_active_outbound_item_reset
(
&
(
*
session_ptr
)
->
aob
);
memset
((
*
session_ptr
)
->
remote_settings
,
0
,
sizeof
((
*
session_ptr
)
->
remote_settings
));
memset
((
*
session_ptr
)
->
local_settings
,
0
,
sizeof
((
*
session_ptr
)
->
local_settings
));
init_settings
((
*
session_ptr
)
->
remote_settings
);
init_settings
((
*
session_ptr
)
->
local_settings
);
...
...
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