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
8d907fb9
Commit
8d907fb9
authored
Oct 13, 2008
by
Eric Wong
Committed by
Max Kellermann
Oct 13, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: use mpd_sizeof_str_flex_array for path, too
This way we avoid unnecessary heap allocations.
parent
8867bd55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
directory.c
src/directory.c
+7
-6
directory.h
src/directory.h
+1
-1
No files found.
src/directory.c
View file @
8d907fb9
...
...
@@ -23,16 +23,18 @@
#include <string.h>
struct
directory
*
directory_new
(
const
char
*
dirname
,
struct
directory
*
parent
)
directory_new
(
const
char
*
path
,
struct
directory
*
parent
)
{
struct
directory
*
directory
;
size_t
pathlen
=
strlen
(
path
);
assert
(
dirname
!=
NULL
);
assert
((
*
dirname
==
0
)
==
(
parent
==
NULL
));
assert
(
path
!=
NULL
);
assert
((
*
path
==
0
)
==
(
parent
==
NULL
));
directory
=
xcalloc
(
1
,
sizeof
(
*
directory
)
);
directory
->
path
=
xstrdup
(
dirname
);
directory
=
xcalloc
(
1
,
sizeof
(
*
directory
)
-
sizeof
(
directory
->
path
)
+
pathlen
+
1
);
directory
->
parent
=
parent
;
memcpy
(
directory
->
path
,
path
,
pathlen
+
1
);
return
directory
;
}
...
...
@@ -42,7 +44,6 @@ directory_free(struct directory *directory)
{
dirvec_destroy
(
&
directory
->
children
);
songvec_destroy
(
&
directory
->
songs
);
free
(
directory
->
path
);
free
(
directory
);
/* this resets last dir returned */
/*directory_get_path(NULL); */
...
...
src/directory.h
View file @
8d907fb9
...
...
@@ -35,13 +35,13 @@
#define DIRECTORY_FS_CHARSET "fs_charset: "
struct
directory
{
char
*
path
;
struct
dirvec
children
;
struct
songvec
songs
;
struct
directory
*
parent
;
ino_t
inode
;
dev_t
device
;
unsigned
stat
;
/* not needed if ino_t == dev_t == 0 is impossible */
char
path
[
sizeof
(
long
)];
};
static
inline
bool
...
...
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