Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
46df0fd7
Commit
46df0fd7
authored
Nov 21, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_curl: moved code to consume_buffer()
Added some assertions.
parent
7779e413
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
input_curl.c
src/input_curl.c
+26
-12
No files found.
src/input_curl.c
View file @
46df0fd7
...
...
@@ -207,6 +207,31 @@ input_curl_select(struct input_curl *c)
return
ret
;
}
/**
* Mark a part of the buffer object as consumed.
*/
static
void
consume_buffer
(
struct
buffer
*
buffer
,
size_t
length
,
struct
list_head
*
rewind_head
)
{
assert
(
buffer
!=
NULL
);
assert
(
buffer
->
consumed
<
buffer
->
size
);
buffer
->
consumed
+=
length
;
if
(
buffer
->
consumed
<
buffer
->
size
)
return
;
assert
(
buffer
->
consumed
==
buffer
->
size
);
list_del
(
&
buffer
->
siblings
);
if
(
rewind_head
!=
NULL
)
/* append this buffer to the rewind buffer list */
list_add_tail
(
&
buffer
->
siblings
,
rewind_head
);
else
g_free
(
buffer
);
}
static
size_t
read_from_buffer
(
struct
buffer
*
buffer
,
void
*
dest
,
size_t
length
,
struct
list_head
*
rewind_head
)
...
...
@@ -218,18 +243,7 @@ read_from_buffer(struct buffer *buffer, void *dest, size_t length,
length
=
buffer
->
size
-
buffer
->
consumed
;
memcpy
(
dest
,
buffer
->
data
+
buffer
->
consumed
,
length
);
buffer
->
consumed
+=
length
;
if
(
buffer
->
consumed
==
buffer
->
size
)
{
list_del
(
&
buffer
->
siblings
);
if
(
rewind_head
!=
NULL
)
/* append this buffer to the rewind buffer list */
list_add_tail
(
&
buffer
->
siblings
,
rewind_head
);
else
g_free
(
buffer
);
}
consume_buffer
(
buffer
,
length
,
rewind_head
);
return
length
;
}
...
...
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