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
0649a7ea
Commit
0649a7ea
authored
Jan 22, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spdylay_buffer_reader_count to replace bunch of 1 byte read
parent
29bec93e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
lib/spdylay_buffer.c
lib/spdylay_buffer.c
+25
-0
lib/spdylay_buffer.h
lib/spdylay_buffer.h
+7
-0
lib/spdylay_frame.c
lib/spdylay_frame.c
+1
-6
No files found.
lib/spdylay_buffer.c
View file @
0649a7ea
...
@@ -201,6 +201,31 @@ void spdylay_buffer_reader_data(spdylay_buffer_reader *reader,
...
@@ -201,6 +201,31 @@ void spdylay_buffer_reader_data(spdylay_buffer_reader *reader,
}
}
}
}
int
spdylay_buffer_reader_count
(
spdylay_buffer_reader
*
reader
,
size_t
len
,
uint8_t
c
)
{
int
res
=
0
;
while
(
len
)
{
size_t
remlen
,
readlen
,
i
;
uint8_t
*
p
;
remlen
=
reader
->
buffer
->
capacity
-
reader
->
offset
;
readlen
=
spdylay_min
(
remlen
,
len
);
p
=
reader
->
current
->
data
+
reader
->
offset
;
for
(
i
=
0
;
i
<
readlen
;
++
i
)
{
if
(
p
[
i
]
==
c
)
{
++
res
;
}
}
len
-=
readlen
;
reader
->
offset
+=
readlen
;
if
(
reader
->
buffer
->
capacity
==
reader
->
offset
)
{
reader
->
current
=
reader
->
current
->
next
;
reader
->
offset
=
0
;
}
}
return
res
;
}
void
spdylay_buffer_reader_advance
(
spdylay_buffer_reader
*
reader
,
void
spdylay_buffer_reader_advance
(
spdylay_buffer_reader
*
reader
,
size_t
amount
)
size_t
amount
)
{
{
...
...
lib/spdylay_buffer.h
View file @
0649a7ea
...
@@ -154,6 +154,13 @@ uint32_t spdylay_buffer_reader_uint32(spdylay_buffer_reader *reader);
...
@@ -154,6 +154,13 @@ uint32_t spdylay_buffer_reader_uint32(spdylay_buffer_reader *reader);
void
spdylay_buffer_reader_data
(
spdylay_buffer_reader
*
reader
,
void
spdylay_buffer_reader_data
(
spdylay_buffer_reader
*
reader
,
uint8_t
*
out
,
size_t
len
);
uint8_t
*
out
,
size_t
len
);
/**
* Reads |len| bytes and count the occurrence of |c| there and return
* it. This function will advance the current position by |len|.
*/
int
spdylay_buffer_reader_count
(
spdylay_buffer_reader
*
reader
,
size_t
len
,
uint8_t
c
);
/*
/*
* Advances the current position by |amount|.
* Advances the current position by |amount|.
*/
*/
...
...
lib/spdylay_frame.c
View file @
0649a7ea
...
@@ -146,12 +146,7 @@ int spdylay_frame_count_unpack_nv_space(size_t *nvlen_ptr, size_t *buflen_ptr,
...
@@ -146,12 +146,7 @@ int spdylay_frame_count_unpack_nv_space(size_t *nvlen_ptr, size_t *buflen_ptr,
spdylay_buffer_reader_advance
(
&
reader
,
len
);
spdylay_buffer_reader_advance
(
&
reader
,
len
);
}
}
}
}
for
(
j
=
off
,
off
-=
len
;
off
!=
j
;
++
off
)
{
nvlen
+=
spdylay_buffer_reader_count
(
&
reader
,
len
,
'\0'
);
uint8_t
b
=
spdylay_buffer_reader_uint8
(
&
reader
);
if
(
b
==
'\0'
)
{
++
nvlen
;
}
}
++
nvlen
;
++
nvlen
;
}
}
if
(
inlen
==
off
)
{
if
(
inlen
==
off
)
{
...
...
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