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
f5a92d6c
Commit
f5a92d6c
authored
Jan 03, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Directory: add constructor and destructor
parent
3e8047e5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
18 deletions
+45
-18
Directory.cxx
src/Directory.cxx
+27
-18
Directory.hxx
src/Directory.hxx
+13
-0
DumpPlaylist.cxx
test/DumpPlaylist.cxx
+3
-0
TestQueuePriority.cxx
test/TestQueuePriority.cxx
+2
-0
No files found.
src/Directory.cxx
View file @
f5a92d6c
...
...
@@ -36,8 +36,8 @@ extern "C" {
#include <string.h>
#include <stdlib.h>
static
Directory
*
directory_a
llocate
(
const
char
*
path
)
inline
Directory
*
Directory
::
A
llocate
(
const
char
*
path
)
{
assert
(
path
!=
NULL
);
...
...
@@ -46,30 +46,21 @@ directory_allocate(const char *path)
(
Directory
*
)
g_malloc0
(
sizeof
(
*
directory
)
-
sizeof
(
directory
->
path
)
+
path_size
);
INIT_LIST_HEAD
(
&
directory
->
children
);
INIT_LIST_HEAD
(
&
directory
->
songs
);
INIT_LIST_HEAD
(
&
directory
->
playlists
);
memcpy
(
directory
->
path
,
path
,
path_size
);
new
(
directory
)
Directory
(
path
);
return
directory
;
}
Directory
*
Directory
::
NewGeneric
(
const
char
*
path
,
Directory
*
parent
)
Directory
::
Directory
(
const
char
*
_path
)
{
assert
(
path
!=
NULL
);
assert
((
*
path
==
0
)
==
(
parent
==
NULL
));
Directory
*
directory
=
directory_allocate
(
path
);
directory
->
parent
=
parent
;
INIT_LIST_HEAD
(
&
children
);
INIT_LIST_HEAD
(
&
songs
);
INIT_LIST_HEAD
(
&
playlists
);
return
directory
;
strcpy
(
path
,
_path
)
;
}
void
Directory
::
Free
()
Directory
::~
Directory
()
{
playlist_vector_deinit
(
&
playlists
);
...
...
@@ -80,7 +71,25 @@ Directory::Free()
Directory
*
child
,
*
n
;
directory_for_each_child_safe
(
child
,
n
,
this
)
child
->
Free
();
}
Directory
*
Directory
::
NewGeneric
(
const
char
*
path
,
Directory
*
parent
)
{
assert
(
path
!=
NULL
);
assert
((
*
path
==
0
)
==
(
parent
==
NULL
));
Directory
*
directory
=
Allocate
(
path
);
directory
->
parent
=
parent
;
return
directory
;
}
void
Directory
::
Free
()
{
this
->
Directory
::~
Directory
();
g_free
(
this
);
}
...
...
src/Directory.hxx
View file @
f5a92d6c
...
...
@@ -90,6 +90,19 @@ struct Directory {
bool
have_stat
;
/* not needed if ino_t == dev_t == 0 is impossible */
char
path
[
sizeof
(
long
)];
protected
:
Directory
(
const
char
*
path
);
gcc_malloc
gcc_nonnull_all
static
Directory
*
Allocate
(
const
char
*
path
);
public
:
/**
* Default constructor, needed for #detached_root.
*/
Directory
()
=
default
;
~
Directory
();
/**
* Generic constructor for #Directory object.
*/
...
...
test/DumpPlaylist.cxx
View file @
f5a92d6c
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "TagSave.hxx"
#include "song.h"
#include "Directory.hxx"
extern
"C"
{
#include "io_thread.h"
...
...
@@ -37,6 +38,8 @@ extern "C" {
#include <unistd.h>
#include <stdlib.h>
Directory
::~
Directory
()
{}
static
void
my_log_func
(
const
gchar
*
log_domain
,
G_GNUC_UNUSED
GLogLevelFlags
log_level
,
const
gchar
*
message
,
G_GNUC_UNUSED
gpointer
user_data
)
...
...
test/TestQueuePriority.cxx
View file @
f5a92d6c
...
...
@@ -7,6 +7,8 @@ extern "C" {
Directory
detached_root
;
Directory
::~
Directory
()
{}
struct
song
*
song_dup_detached
(
const
struct
song
*
src
)
{
...
...
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