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
a3c888d7
Commit
a3c888d7
authored
Dec 05, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp2_map: Implement hash table
parent
1f0dfd43
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
250 deletions
+126
-250
lib/nghttp2_map.c
lib/nghttp2_map.c
+102
-240
lib/nghttp2_map.h
lib/nghttp2_map.h
+14
-7
lib/nghttp2_session.c
lib/nghttp2_session.c
+8
-3
tests/nghttp2_map_test.c
tests/nghttp2_map_test.c
+2
-0
No files found.
lib/nghttp2_map.c
View file @
a3c888d7
This diff is collapsed.
Click to expand it.
lib/nghttp2_map.h
View file @
a3c888d7
...
...
@@ -32,26 +32,31 @@
#include <nghttp2/nghttp2.h>
#include "nghttp2_int.h"
/* Implementation of ordered map */
/* Implementation of
un
ordered map */
typedef
uint32_t
key_type
;
typedef
uint32_t
pri_type
;
typedef
struct
nghttp2_map_entry
{
key_type
key
;
struct
nghttp2_map_entry
*
parent
,
*
left
,
*
right
;
pri_type
priority
;
struct
nghttp2_map_entry
*
next
;
}
nghttp2_map_entry
;
typedef
struct
{
nghttp2_map_entry
*
root
;
nghttp2_map_entry
**
table
;
size_t
tablelen
;
size_t
size
;
}
nghttp2_map
;
/*
* Initializes the map |map|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP2_ERR_NOMEM
* Out of memory
*/
void
nghttp2_map_init
(
nghttp2_map
*
map
);
int
nghttp2_map_init
(
nghttp2_map
*
map
);
/*
* Deallocates any resources allocated for |map|. The stored entries
...
...
@@ -80,10 +85,12 @@ void nghttp2_map_entry_init(nghttp2_map_entry *entry, key_type key);
* Inserts the new |entry| with the key |entry->key| to the map |map|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error code:
* negative error code
s
:
*
* NGHTTP2_ERR_INVALID_ARGUMENT
* The item associated by |key| already exists.
* NGHTTP2_ERR_NOMEM
* Out of memory
*/
int
nghttp2_map_insert
(
nghttp2_map
*
map
,
nghttp2_map_entry
*
entry
);
...
...
lib/nghttp2_session.c
View file @
a3c888d7
...
...
@@ -233,7 +233,10 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
if
(
r
!=
0
)
{
goto
fail_hd_inflater
;
}
nghttp2_map_init
(
&
(
*
session_ptr
)
->
streams
);
r
=
nghttp2_map_init
(
&
(
*
session_ptr
)
->
streams
);
if
(
r
!=
0
)
{
goto
fail_map
;
}
r
=
nghttp2_pq_init
(
&
(
*
session_ptr
)
->
ob_pq
,
nghttp2_outbound_item_compar
);
if
(
r
!=
0
)
{
goto
fail_ob_pq
;
...
...
@@ -294,7 +297,8 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
fail_ob_ss_pq:
nghttp2_pq_free
(
&
(
*
session_ptr
)
->
ob_pq
);
fail_ob_pq:
/* No need to free (*session_ptr)->streams) here. */
nghttp2_map_free
(
&
(
*
session_ptr
)
->
streams
);
fail_map:
nghttp2_hd_inflate_free
(
&
(
*
session_ptr
)
->
hd_inflater
);
fail_hd_inflater:
nghttp2_hd_deflate_free
(
&
(
*
session_ptr
)
->
hd_deflater
);
...
...
@@ -389,6 +393,7 @@ void nghttp2_session_del(nghttp2_session *session)
free
(
session
->
inflight_iv
);
nghttp2_inbound_frame_reset
(
session
);
nghttp2_map_each_free
(
&
session
->
streams
,
nghttp2_free_streams
,
NULL
);
nghttp2_map_free
(
&
session
->
streams
);
nghttp2_session_ob_pq_free
(
&
session
->
ob_pq
);
nghttp2_session_ob_pq_free
(
&
session
->
ob_ss_pq
);
nghttp2_hd_deflate_free
(
&
session
->
hd_deflater
);
...
...
@@ -397,7 +402,7 @@ void nghttp2_session_del(nghttp2_session *session)
free
(
session
->
aob
.
framebuf
);
free
(
session
->
nvbuf
);
free
(
session
->
iframe
.
buf
);
free
(
session
);
free
(
session
);
}
static
int
outbound_item_update_pri
...
...
tests/nghttp2_map_test.c
View file @
a3c888d7
...
...
@@ -149,6 +149,7 @@ void test_nghttp2_map_functional(void)
CU_ASSERT
(
0
==
nghttp2_map_insert
(
&
map
,
&
arr
[
i
].
map_entry
));
}
nghttp2_map_each_free
(
&
map
,
eachfun
,
NULL
);
nghttp2_map_free
(
&
map
);
}
static
int
entry_free
(
nghttp2_map_entry
*
entry
,
void
*
ptr
)
...
...
@@ -177,4 +178,5 @@ void test_nghttp2_map_each_free(void)
nghttp2_map_insert
(
&
map
,
&
shrubbery
->
map_entry
);
nghttp2_map_each_free
(
&
map
,
entry_free
,
NULL
);
nghttp2_map_free
(
&
map
);
}
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