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
bc966577
Commit
bc966577
authored
Jan 18, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Song: use the VarSize library
parent
fdf4dff5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
Song.cxx
src/Song.cxx
+16
-13
Song.hxx
src/Song.hxx
+3
-0
No files found.
src/Song.cxx
View file @
bc966577
...
...
@@ -21,13 +21,24 @@
#include "Song.hxx"
#include "Directory.hxx"
#include "tag/Tag.hxx"
#include "util/
Alloc
.hxx"
#include "util/
VarSize
.hxx"
#include "DetachedSong.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
inline
Song
::
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
*
_parent
)
:
tag
(
nullptr
),
parent
(
_parent
),
mtime
(
0
),
start_ms
(
0
),
end_ms
(
0
)
{
memcpy
(
uri
,
_uri
,
uri_length
+
1
);
}
inline
Song
::~
Song
()
{
delete
tag
;
}
static
Song
*
song_alloc
(
const
char
*
uri
,
Directory
*
parent
)
{
...
...
@@ -37,16 +48,9 @@ song_alloc(const char *uri, Directory *parent)
uri_length
=
strlen
(
uri
);
assert
(
uri_length
);
Song
*
song
=
(
Song
*
)
xalloc
(
sizeof
(
*
song
)
-
sizeof
(
song
->
uri
)
+
uri_length
+
1
);
song
->
tag
=
nullptr
;
memcpy
(
song
->
uri
,
uri
,
uri_length
+
1
);
song
->
parent
=
parent
;
song
->
mtime
=
0
;
song
->
start_ms
=
song
->
end_ms
=
0
;
return
song
;
return
NewVarSize
<
Song
>
(
sizeof
(
Song
::
uri
),
uri_length
+
1
,
uri
,
uri_length
,
parent
);
}
Song
*
...
...
@@ -69,8 +73,7 @@ Song::NewFile(const char *path, Directory *parent)
void
Song
::
Free
()
{
delete
tag
;
free
(
this
);
DeleteVarSize
(
this
);
}
std
::
string
...
...
src/Song.hxx
View file @
bc966577
...
...
@@ -77,6 +77,9 @@ struct Song {
*/
char
uri
[
sizeof
(
int
)];
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
*
parent
);
~
Song
();
gcc_malloc
static
Song
*
NewFrom
(
DetachedSong
&&
other
,
Directory
*
parent
);
...
...
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