Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Icecast-Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
94
Issues
94
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
Icecast-Server
Commits
934cc322
Commit
934cc322
authored
Sep 20, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature: Added a way to push buffers into buffers
parent
71b156af
Pipeline
#320
failed with stage
in 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
src/buffer.c
src/buffer.c
+16
-0
src/buffer.h
src/buffer.h
+9
-0
src/tests/ctest_buffer.c
src/tests/ctest_buffer.c
+26
-0
No files found.
src/buffer.c
View file @
934cc322
...
...
@@ -264,6 +264,22 @@ int buffer_push_vprintf(buffer_t *buffer, const char *format, va_list ap
return
buffer_zerocopy_push_complete
(
buffer
,
ret
);
}
int
buffer_push_buffer
(
buffer_t
*
buffer
,
buffer_t
*
source
)
{
const
void
*
data
;
size_t
length
;
int
ret
;
if
(
!
buffer
||
!
source
)
return
-
1
;
ret
=
buffer_get_data
(
source
,
&
data
,
&
length
);
if
(
ret
!=
0
)
return
ret
;
return
buffer_push_data
(
buffer
,
data
,
length
);
}
int
buffer_zerocopy_push_request
(
buffer_t
*
buffer
,
void
**
data
,
size_t
request
)
{
if
(
!
buffer
||
!
data
)
...
...
src/buffer.h
View file @
934cc322
...
...
@@ -153,6 +153,15 @@ int buffer_push_printf(buffer_t *buffer, const char *format, ...);
*/
int
buffer_push_vprintf
(
buffer_t
*
buffer
,
const
char
*
format
,
va_list
ap
);
/* This pushes the content of another buffer to the end of the buffer.
* Parameters:
* buffer
* The buffer to operate on.
* source
* The buffer which's content is to be copied.
*/
int
buffer_push_buffer
(
buffer_t
*
buffer
,
buffer_t
*
source
);
/* This requests for a memory buffer that can be pushed to without the need for copy.
* Parameters:
* buffer
...
...
src/tests/ctest_buffer.c
View file @
934cc322
...
...
@@ -303,6 +303,31 @@ static void test_printf(void)
ctest_test
(
"un-referenced"
,
refobject_unref
(
a
)
==
0
);
}
static
void
test_push_buffer
(
void
)
{
buffer_t
*
a
;
buffer_t
*
b
;
const
char
*
pattern
=
"AABBBCC"
;
const
char
*
match_a
=
"AABBBCCAABBBCC"
;
a
=
buffer_new_simple
();
ctest_test
(
"buffer a created"
,
a
!=
NULL
);
b
=
buffer_new_simple
();
ctest_test
(
"buffer b created"
,
b
!=
NULL
);
ctest_test
(
"pushed string"
,
buffer_push_string
(
a
,
pattern
)
==
0
);
test__compare_to_string
(
a
,
"string matches input"
,
pattern
);
ctest_test
(
"pushed buffer a to b"
,
buffer_push_buffer
(
b
,
a
)
==
0
);
test__compare_to_string
(
b
,
"string matches input"
,
pattern
);
ctest_test
(
"pushed buffer a to b"
,
buffer_push_buffer
(
b
,
a
)
==
0
);
test__compare_to_string
(
b
,
"string matches pattern a"
,
match_a
);
ctest_test
(
"un-referenced b"
,
refobject_unref
(
b
)
==
0
);
ctest_test
(
"un-referenced a"
,
refobject_unref
(
a
)
==
0
);
}
int
main
(
void
)
{
ctest_init
();
...
...
@@ -322,6 +347,7 @@ int main (void)
test_length
();
test_printf
();
test_push_buffer
();
ctest_fin
();
...
...
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