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
1f523be7
Commit
1f523be7
authored
Dec 15, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/PeakBuffer: return ConstBuffer<void>
parent
f2a20a0a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
FullyBufferedSocket.cxx
src/event/FullyBufferedSocket.cxx
+3
-4
PeakBuffer.cxx
src/util/PeakBuffer.cxx
+8
-6
PeakBuffer.hxx
src/util/PeakBuffer.hxx
+5
-1
No files found.
src/event/FullyBufferedSocket.cxx
View file @
1f523be7
...
@@ -60,15 +60,14 @@ FullyBufferedSocket::Flush()
...
@@ -60,15 +60,14 @@ FullyBufferedSocket::Flush()
{
{
assert
(
IsDefined
());
assert
(
IsDefined
());
size_t
length
;
const
auto
data
=
output
.
Read
();
const
void
*
data
=
output
.
Read
(
&
length
);
if
(
data
.
IsNull
())
{
if
(
data
==
nullptr
)
{
IdleMonitor
::
Cancel
();
IdleMonitor
::
Cancel
();
CancelWrite
();
CancelWrite
();
return
true
;
return
true
;
}
}
auto
nbytes
=
DirectWrite
(
data
,
length
);
auto
nbytes
=
DirectWrite
(
data
.
data
,
data
.
size
);
if
(
gcc_unlikely
(
nbytes
<=
0
))
if
(
gcc_unlikely
(
nbytes
<=
0
))
return
nbytes
==
0
;
return
nbytes
==
0
;
...
...
src/util/PeakBuffer.cxx
View file @
1f523be7
...
@@ -45,19 +45,21 @@ PeakBuffer::IsEmpty() const
...
@@ -45,19 +45,21 @@ PeakBuffer::IsEmpty() const
fifo_buffer_is_empty
(
peak_buffer
));
fifo_buffer_is_empty
(
peak_buffer
));
}
}
const
void
*
ConstBuffer
<
void
>
PeakBuffer
::
Read
(
size_t
*
length_r
)
const
PeakBuffer
::
Read
()
const
{
{
if
(
normal_buffer
!=
nullptr
)
{
if
(
normal_buffer
!=
nullptr
)
{
const
void
*
p
=
fifo_buffer_read
(
normal_buffer
,
length_r
);
size_t
size
;
const
void
*
p
=
fifo_buffer_read
(
normal_buffer
,
&
size
);
if
(
p
!=
nullptr
)
if
(
p
!=
nullptr
)
return
p
;
return
{
p
,
size
}
;
}
}
if
(
peak_buffer
!=
nullptr
)
{
if
(
peak_buffer
!=
nullptr
)
{
const
void
*
p
=
fifo_buffer_read
(
peak_buffer
,
length_r
);
size_t
size
;
const
void
*
p
=
fifo_buffer_read
(
peak_buffer
,
&
size
);
if
(
p
!=
nullptr
)
if
(
p
!=
nullptr
)
return
p
;
return
{
p
,
size
}
;
}
}
return
nullptr
;
return
nullptr
;
...
...
src/util/PeakBuffer.hxx
View file @
1f523be7
...
@@ -20,11 +20,13 @@
...
@@ -20,11 +20,13 @@
#ifndef MPD_PEAK_BUFFER_HXX
#ifndef MPD_PEAK_BUFFER_HXX
#define MPD_PEAK_BUFFER_HXX
#define MPD_PEAK_BUFFER_HXX
#include "ConstBuffer.hxx"
#include "Compiler.h"
#include "Compiler.h"
#include <stddef.h>
#include <stddef.h>
struct
fifo_buffer
;
struct
fifo_buffer
;
template
<
typename
T
>
struct
ConstBuffer
;
/**
/**
* A FIFO-like buffer that will allocate more memory on demand to
* A FIFO-like buffer that will allocate more memory on demand to
...
@@ -57,7 +59,9 @@ public:
...
@@ -57,7 +59,9 @@ public:
gcc_pure
gcc_pure
bool
IsEmpty
()
const
;
bool
IsEmpty
()
const
;
const
void
*
Read
(
size_t
*
length_r
)
const
;
gcc_pure
ConstBuffer
<
void
>
Read
()
const
;
void
Consume
(
size_t
length
);
void
Consume
(
size_t
length
);
bool
Append
(
const
void
*
data
,
size_t
length
);
bool
Append
(
const
void
*
data
,
size_t
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