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
0bfe7802
Commit
0bfe7802
authored
Oct 08, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: path must not be NULL
For the root directory, let's set path to an empty string. This saves a few checks.
parent
3b6efa99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
database.c
src/database.c
+2
-2
directory.c
src/directory.c
+7
-7
directory.h
src/directory.h
+0
-2
No files found.
src/database.c
View file @
0bfe7802
...
...
@@ -39,7 +39,7 @@ static time_t directory_dbModTime;
void
db_init
(
void
)
{
music_root
=
directory_new
(
NULL
,
NULL
);
music_root
=
directory_new
(
""
,
NULL
);
updateDirectory
(
music_root
);
stats
.
numberOfSongs
=
countSongsIn
(
NULL
);
stats
.
dbPlayTime
=
sumSongTimesIn
(
NULL
);
...
...
@@ -240,7 +240,7 @@ db_load(void)
struct
stat
st
;
if
(
!
music_root
)
music_root
=
directory_new
(
NULL
,
NULL
);
music_root
=
directory_new
(
""
,
NULL
);
while
(
!
(
fp
=
fopen
(
dbFile
,
"r"
))
&&
errno
==
EINTR
)
;
if
(
fp
==
NULL
)
{
ERROR
(
"unable to open db file
\"
%s
\"
: %s
\n
"
,
...
...
src/directory.c
View file @
0bfe7802
...
...
@@ -32,10 +32,11 @@ directory_new(const char *dirname, struct directory *parent)
{
struct
directory
*
directory
;
directory
=
xcalloc
(
1
,
sizeof
(
*
directory
));
assert
(
dirname
!=
NULL
);
assert
((
*
dirname
==
0
)
==
(
parent
==
NULL
));
if
(
dirname
&&
strlen
(
dirname
))
directory
->
path
=
xstrdup
(
dirname
);
directory
=
xcalloc
(
1
,
sizeof
(
*
directory
));
directory
->
path
=
xstrdup
(
dirname
);
directory
->
parent
=
parent
;
return
directory
;
...
...
@@ -46,8 +47,7 @@ directory_free(struct directory *directory)
{
dirvec_destroy
(
&
directory
->
children
);
songvec_destroy
(
&
directory
->
songs
);
if
(
directory
->
path
)
free
(
directory
->
path
);
free
(
directory
->
path
);
free
(
directory
);
/* this resets last dir returned */
/*directory_get_path(NULL); */
...
...
@@ -131,7 +131,7 @@ directory_save(FILE *fp, struct directory *directory)
size_t
i
;
int
retv
;
if
(
directory
->
path
)
{
if
(
!
isRootDirectory
(
directory
->
path
)
)
{
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
directory_get_path
(
directory
));
if
(
retv
<
0
)
...
...
@@ -151,7 +151,7 @@ directory_save(FILE *fp, struct directory *directory)
songvec_save
(
fp
,
&
directory
->
songs
);
if
(
directory
->
path
&&
if
(
!
isRootDirectory
(
directory
->
path
)
&&
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
directory_get_path
(
directory
))
<
0
)
return
-
1
;
...
...
src/directory.h
View file @
0bfe7802
...
...
@@ -73,8 +73,6 @@ directory_is_empty(struct directory *directory)
static
inline
const
char
*
directory_get_path
(
struct
directory
*
directory
)
{
if
(
directory
->
path
==
NULL
)
return
""
;
return
directory
->
path
;
}
...
...
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