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
8b193107
Commit
8b193107
authored
Feb 19, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd/Page: no variable size, use AllocatedArray
Using variable-size objects is not worth the trouble here. Let's drop this and use existing and simpler code.
parent
45e15b6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
23 deletions
+12
-23
Page.cxx
src/output/plugins/httpd/Page.cxx
+4
-11
Page.hxx
src/output/plugins/httpd/Page.hxx
+8
-12
No files found.
src/output/plugins/httpd/Page.cxx
View file @
8b193107
...
...
@@ -19,9 +19,6 @@
#include "config.h"
#include "Page.hxx"
#include "util/Alloc.hxx"
#include <new>
#include <assert.h>
#include <string.h>
...
...
@@ -30,9 +27,7 @@
Page
*
Page
::
Create
(
size_t
size
)
{
void
*
p
=
xalloc
(
sizeof
(
Page
)
+
size
-
sizeof
(
Page
::
data
));
return
::
new
(
p
)
Page
(
size
);
return
new
Page
(
size
);
}
Page
*
...
...
@@ -41,7 +36,7 @@ Page::Copy(const void *data, size_t size)
assert
(
data
!=
nullptr
);
Page
*
page
=
Create
(
size
);
memcpy
(
page
->
data
,
data
,
size
);
memcpy
(
&
page
->
buffer
.
front
()
,
data
,
size
);
return
page
;
}
...
...
@@ -50,10 +45,8 @@ Page::Unref()
{
bool
unused
=
ref
.
Decrement
();
if
(
unused
)
{
this
->
Page
::~
Page
();
free
(
this
);
}
if
(
unused
)
delete
this
;
return
unused
;
}
src/output/plugins/httpd/Page.hxx
View file @
8b193107
...
...
@@ -26,6 +26,7 @@
#define MPD_PAGE_HXX
#include "util/RefCount.hxx"
#include "util/AllocatedArray.hxx"
#include <stddef.h>
#include <stdint.h>
...
...
@@ -44,18 +45,13 @@ class Page {
*/
RefCount
ref
;
/**
* The size of this buffer in bytes.
*/
const
size_t
size
;
/**
* Dynamic array containing the buffer data.
*/
uint8_t
data
[
sizeof
(
long
)];
AllocatedArray
<
uint8_t
>
buffer
;
protected
:
Page
(
size_t
_size
)
:
size
(
_size
)
{}
explicit
Page
(
size_t
_size
)
:
buffer
(
_size
)
{}
explicit
Page
(
AllocatedArray
<
uint8_t
>
&&
_buffer
)
:
buffer
(
std
::
move
(
_buffer
))
{}
~
Page
()
=
default
;
/**
...
...
@@ -91,11 +87,11 @@ public:
bool
Unref
();
size_t
GetSize
()
const
{
return
size
;
return
buffer
.
size
()
;
}
const
uint8_t
*
GetData
()
const
{
return
data
;
return
&
buffer
.
front
()
;
}
};
...
...
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