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
0666a73e
Commit
0666a73e
authored
Mar 11, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove nghttp2_buffer
parent
3f56c938
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
3 additions
and
292 deletions
+3
-292
lib/Makefile.am
lib/Makefile.am
+2
-2
lib/nghttp2_buffer.c
lib/nghttp2_buffer.c
+0
-94
lib/nghttp2_buffer.h
lib/nghttp2_buffer.h
+0
-103
lib/nghttp2_frame.h
lib/nghttp2_frame.h
+0
-1
lib/nghttp2_session.h
lib/nghttp2_session.h
+0
-1
tests/Makefile.am
tests/Makefile.am
+1
-2
tests/main.c
tests/main.c
+0
-2
tests/nghttp2_buffer_test.c
tests/nghttp2_buffer_test.c
+0
-56
tests/nghttp2_buffer_test.h
tests/nghttp2_buffer_test.h
+0
-31
No files found.
lib/Makefile.am
View file @
0666a73e
...
...
@@ -32,7 +32,7 @@ DISTCLEANFILES = $(pkgconfig_DATA)
lib_LTLIBRARIES
=
libnghttp2.la
OBJECTS
=
nghttp2_pq.c nghttp2_map.c nghttp2_queue.c
\
nghttp2_
buffer.c nghttp2_
frame.c
\
nghttp2_frame.c
\
nghttp2_buf.c
\
nghttp2_stream.c nghttp2_outbound_item.c
\
nghttp2_session.c nghttp2_submit.c
\
...
...
@@ -42,7 +42,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
nghttp2_version.c
HFILES
=
nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h
\
nghttp2_
buffer.h nghttp2_
frame.h
\
nghttp2_frame.h
\
nghttp2_buf.h
\
nghttp2_session.h nghttp2_helper.h nghttp2_stream.h nghttp2_int.h
\
nghttp2_npn.h nghttp2_gzip.h
\
...
...
lib/nghttp2_buffer.c
deleted
100644 → 0
View file @
3f56c938
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2014 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "nghttp2_buffer.h"
#include <assert.h>
#include <string.h>
#include "nghttp2_helper.h"
void
nghttp2_buffer_init
(
nghttp2_buffer
*
buffer
,
size_t
max_capacity
)
{
buffer
->
buf
=
NULL
;
buffer
->
len
=
0
;
buffer
->
capacity
=
0
;
buffer
->
max_capacity
=
max_capacity
;
}
void
nghttp2_buffer_free
(
nghttp2_buffer
*
buffer
)
{
free
(
buffer
->
buf
);
}
int
nghttp2_buffer_reserve
(
nghttp2_buffer
*
buffer
,
size_t
len
)
{
if
(
len
>
buffer
->
max_capacity
)
{
return
NGHTTP2_ERR_BUFFER_ERROR
;
}
if
(
buffer
->
capacity
<
len
)
{
uint8_t
*
new_buf
;
size_t
new_cap
=
buffer
->
capacity
==
0
?
8
:
buffer
->
capacity
*
3
/
2
;
new_cap
=
nghttp2_min
(
buffer
->
max_capacity
,
nghttp2_max
(
new_cap
,
len
));
new_buf
=
realloc
(
buffer
->
buf
,
new_cap
);
if
(
new_buf
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
buffer
->
buf
=
new_buf
;
buffer
->
capacity
=
new_cap
;
}
return
0
;
}
int
nghttp2_buffer_add
(
nghttp2_buffer
*
buffer
,
const
uint8_t
*
data
,
size_t
len
)
{
int
rv
;
rv
=
nghttp2_buffer_reserve
(
buffer
,
buffer
->
len
+
len
);
if
(
rv
!=
0
)
{
return
rv
;
}
memcpy
(
buffer
->
buf
+
buffer
->
len
,
data
,
len
);
buffer
->
len
+=
len
;
return
0
;
}
int
nghttp2_buffer_add_byte
(
nghttp2_buffer
*
buffer
,
uint8_t
b
)
{
int
rv
;
rv
=
nghttp2_buffer_reserve
(
buffer
,
buffer
->
len
+
1
);
if
(
rv
!=
0
)
{
return
rv
;
}
buffer
->
buf
[
buffer
->
len
]
=
b
;
++
buffer
->
len
;
return
0
;
}
void
nghttp2_buffer_release
(
nghttp2_buffer
*
buffer
)
{
buffer
->
buf
=
NULL
;
buffer
->
len
=
0
;
buffer
->
capacity
=
0
;
}
lib/nghttp2_buffer.h
deleted
100644 → 0
View file @
3f56c938
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2014 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NGHTTP2_BUFFER_H
#define NGHTTP2_BUFFER_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* HAVE_CONFIG_H */
#include <nghttp2/nghttp2.h>
#include "nghttp2_int.h"
/*
* Byte array buffer
*/
typedef
struct
{
uint8_t
*
buf
;
/* Capacity of this buffer */
size_t
capacity
;
/* How many bytes are written to buf. len <= capacity must hold. */
size_t
len
;
/* Maximum capacity this buffer can grow up */
size_t
max_capacity
;
}
nghttp2_buffer
;
void
nghttp2_buffer_init
(
nghttp2_buffer
*
buffer
,
size_t
max_capacity
);
void
nghttp2_buffer_free
(
nghttp2_buffer
*
buffer
);
/*
* Expands capacity so that it can contain at least |len| bytes of
* data. If buffer->capacity >= len, no action is taken. If len >
* buffer->max_capacity, NGHTTP2_ERR_BUFFER_ERROR is returned.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP2_ERR_BUFFER_ERROR
* The |len| is strictly larger than buffer->max_capacity
* NGHTTP2_ERR_NOMEM
* Out of memory
*/
int
nghttp2_buffer_reserve
(
nghttp2_buffer
*
buffer
,
size_t
len
);
/*
* Appends the |data| with |len| bytes to the buffer. The data is
* copied. The |buffer| will be expanded as needed.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP2_ERR_BUFFER_ERROR
* The |len| is strictly larger than buffer->max_capacity
* NGHTTP2_ERR_NOMEM
* Out of memory
*/
int
nghttp2_buffer_add
(
nghttp2_buffer
*
buffer
,
const
uint8_t
*
data
,
size_t
len
);
/*
* Appends the a single byte|b| to the buffer. The data is copied. The
* |buffer| will be expanded as needed.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP2_ERR_BUFFER_ERROR
* The |len| is strictly larger than buffer->max_capacity
* NGHTTP2_ERR_NOMEM
* Out of memory
*/
int
nghttp2_buffer_add_byte
(
nghttp2_buffer
*
buffer
,
uint8_t
b
);
/*
* Releases the buffer without freeing it. The data members in buffer
* is initialized.
*/
void
nghttp2_buffer_release
(
nghttp2_buffer
*
buffer
);
#endif
/* NGHTTP2_BUFFER_H */
lib/nghttp2_frame.h
View file @
0666a73e
...
...
@@ -31,7 +31,6 @@
#include <nghttp2/nghttp2.h>
#include "nghttp2_hd.h"
#include "nghttp2_buffer.h"
#include "nghttp2_buf.h"
#define NGHTTP2_FRAME_LENGTH_MASK ((1 << 14) - 1)
...
...
lib/nghttp2_session.h
View file @
0666a73e
...
...
@@ -35,7 +35,6 @@
#include "nghttp2_frame.h"
#include "nghttp2_hd.h"
#include "nghttp2_stream.h"
#include "nghttp2_buffer.h"
#include "nghttp2_outbound_item.h"
#include "nghttp2_int.h"
#include "nghttp2_buf.h"
...
...
tests/Makefile.am
View file @
0666a73e
...
...
@@ -31,7 +31,6 @@ check_PROGRAMS += failmalloc
endif
# ENABLE_FAILMALLOC
OBJECTS
=
main.c nghttp2_pq_test.c nghttp2_map_test.c nghttp2_queue_test.c
\
nghttp2_buffer_test.c
\
nghttp2_test_helper.c
\
nghttp2_frame_test.c
\
nghttp2_stream_test.c
\
...
...
@@ -42,7 +41,7 @@ OBJECTS = main.c nghttp2_pq_test.c nghttp2_map_test.c nghttp2_queue_test.c \
nghttp2_helper_test.c
HFILES
=
nghttp2_pq_test.h nghttp2_map_test.h nghttp2_queue_test.h
\
nghttp2_
buffer_test.h nghttp2_
session_test.h
\
nghttp2_session_test.h
\
nghttp2_frame_test.h nghttp2_stream_test.h nghttp2_hd_test.h
\
nghttp2_npn_test.h nghttp2_gzip_test.h nghttp2_helper_test.h
\
nghttp2_test_helper.h
...
...
tests/main.c
View file @
0666a73e
...
...
@@ -29,7 +29,6 @@
#include "nghttp2_pq_test.h"
#include "nghttp2_map_test.h"
#include "nghttp2_queue_test.h"
#include "nghttp2_buffer_test.h"
#include "nghttp2_session_test.h"
#include "nghttp2_frame_test.h"
#include "nghttp2_stream_test.h"
...
...
@@ -72,7 +71,6 @@ int main(int argc, char* argv[])
!
CU_add_test
(
pSuite
,
"map_functional"
,
test_nghttp2_map_functional
)
||
!
CU_add_test
(
pSuite
,
"map_each_free"
,
test_nghttp2_map_each_free
)
||
!
CU_add_test
(
pSuite
,
"queue"
,
test_nghttp2_queue
)
||
!
CU_add_test
(
pSuite
,
"buffer"
,
test_nghttp2_buffer
)
||
!
CU_add_test
(
pSuite
,
"npn"
,
test_nghttp2_npn
)
||
!
CU_add_test
(
pSuite
,
"session_recv"
,
test_nghttp2_session_recv
)
||
!
CU_add_test
(
pSuite
,
"session_recv_invalid_stream_id"
,
...
...
tests/nghttp2_buffer_test.c
deleted
100644 → 0
View file @
3f56c938
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2012 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "nghttp2_buffer_test.h"
#include <stdio.h>
#include <CUnit/CUnit.h>
#include "nghttp2_buffer.h"
void
test_nghttp2_buffer
(
void
)
{
nghttp2_buffer
buffer
;
nghttp2_buffer_init
(
&
buffer
,
16
);
CU_ASSERT
(
0
==
buffer
.
len
);
CU_ASSERT
(
0
==
nghttp2_buffer_add
(
&
buffer
,
(
const
uint8_t
*
)
"foo"
,
3
));
CU_ASSERT
(
3
==
buffer
.
len
);
CU_ASSERT
(
0
==
nghttp2_buffer_add_byte
(
&
buffer
,
'.'
));
CU_ASSERT
(
4
==
buffer
.
len
);
CU_ASSERT
(
0
==
nghttp2_buffer_add
(
&
buffer
,
(
const
uint8_t
*
)
"012345678901"
,
12
));
CU_ASSERT
(
16
==
buffer
.
len
);
CU_ASSERT
(
NGHTTP2_ERR_BUFFER_ERROR
==
nghttp2_buffer_add_byte
(
&
buffer
,
'.'
));
CU_ASSERT
(
NGHTTP2_ERR_BUFFER_ERROR
==
nghttp2_buffer_add
(
&
buffer
,
(
const
uint8_t
*
)
"."
,
1
));
nghttp2_buffer_free
(
&
buffer
);
}
tests/nghttp2_buffer_test.h
deleted
100644 → 0
View file @
3f56c938
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2012 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NGHTTP2_BUFFER_TEST_H
#define NGHTTP2_BUFFER_TEST_H
void
test_nghttp2_buffer
(
void
);
void
test_nghttp2_buffer_reader
(
void
);
#endif
/* NGHTTP2_BUFFER_TEST_H */
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