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
8ef134a7
Commit
8ef134a7
authored
Oct 21, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp_hd: Refactor emit_indname_block and emit_newname_block
parent
28aea5c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
26 deletions
+25
-26
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+25
-26
No files found.
lib/nghttp2_hd.c
View file @
8ef134a7
...
@@ -575,6 +575,24 @@ static int emit_indexed_block(uint8_t **buf_ptr, size_t *buflen_ptr,
...
@@ -575,6 +575,24 @@ static int emit_indexed_block(uint8_t **buf_ptr, size_t *buflen_ptr,
return
0
;
return
0
;
}
}
static
size_t
emit_string
(
uint8_t
*
buf
,
size_t
buflen
,
size_t
enclen
,
int
huffman
,
const
uint8_t
*
str
,
size_t
len
,
nghttp2_hd_side
side
)
{
size_t
rv
;
*
buf
=
huffman
?
1
<<
7
:
0
;
rv
=
encode_length
(
buf
,
enclen
,
7
);
buf
+=
rv
;
if
(
huffman
)
{
nghttp2_hd_huff_encode
(
buf
,
buflen
-
rv
,
str
,
len
,
side
);
}
else
{
assert
(
enclen
==
len
);
memcpy
(
buf
,
str
,
len
);
}
return
rv
+
enclen
;
}
static
int
emit_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
static
int
emit_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
size_t
*
offset_ptr
,
size_t
index
,
size_t
*
offset_ptr
,
size_t
index
,
const
uint8_t
*
value
,
size_t
valuelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
...
@@ -597,15 +615,9 @@ static int emit_indname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
...
@@ -597,15 +615,9 @@ static int emit_indname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
bufp
=
*
buf_ptr
+
*
offset_ptr
;
bufp
=
*
buf_ptr
+
*
offset_ptr
;
*
bufp
=
inc_indexing
?
0
:
0x40u
;
*
bufp
=
inc_indexing
?
0
:
0x40u
;
bufp
+=
encode_length
(
bufp
,
index
+
1
,
6
);
bufp
+=
encode_length
(
bufp
,
index
+
1
,
6
);
*
bufp
=
huffman
?
1
<<
7
:
0
;
bufp
+=
emit_string
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
bufp
+=
encode_length
(
bufp
,
encvallen
,
7
);
encvallen
,
huffman
,
value
,
valuelen
,
side
);
if
(
huffman
)
{
assert
(
bufp
-
(
*
buf_ptr
+
*
offset_ptr
)
==
(
ssize_t
)
blocklen
);
nghttp2_hd_huff_encode
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
value
,
valuelen
,
side
);
}
else
{
memcpy
(
bufp
,
value
,
valuelen
);
}
assert
(
bufp
+
encvallen
-
(
*
buf_ptr
+
*
offset_ptr
)
==
(
ssize_t
)
blocklen
);
*
offset_ptr
+=
blocklen
;
*
offset_ptr
+=
blocklen
;
return
0
;
return
0
;
}
}
...
@@ -638,23 +650,10 @@ static int emit_newname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
...
@@ -638,23 +650,10 @@ static int emit_newname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
}
}
bufp
=
*
buf_ptr
+
*
offset_ptr
;
bufp
=
*
buf_ptr
+
*
offset_ptr
;
*
bufp
++
=
inc_indexing
?
0
:
0x40u
;
*
bufp
++
=
inc_indexing
?
0
:
0x40u
;
*
bufp
=
name_huffman
?
1
<<
7
:
0
;
bufp
+=
emit_string
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
bufp
+=
encode_length
(
bufp
,
encnamelen
,
7
);
encnamelen
,
name_huffman
,
nv
->
name
,
nv
->
namelen
,
side
);
if
(
name_huffman
)
{
bufp
+=
emit_string
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
nghttp2_hd_huff_encode
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
encvallen
,
value_huffman
,
nv
->
value
,
nv
->
valuelen
,
side
);
nv
->
name
,
nv
->
namelen
,
side
);
}
else
{
memcpy
(
bufp
,
nv
->
name
,
nv
->
namelen
);
}
bufp
+=
encnamelen
;
*
bufp
=
value_huffman
?
1
<<
7
:
0
;
bufp
+=
encode_length
(
bufp
,
encvallen
,
7
);
if
(
value_huffman
)
{
nghttp2_hd_huff_encode
(
bufp
,
*
buflen_ptr
-
(
bufp
-
*
buf_ptr
),
nv
->
value
,
nv
->
valuelen
,
side
);
}
else
{
memcpy
(
bufp
,
nv
->
value
,
nv
->
valuelen
);
}
*
offset_ptr
+=
blocklen
;
*
offset_ptr
+=
blocklen
;
return
0
;
return
0
;
}
}
...
...
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