aboutsummaryrefslogtreecommitdiffstats
path: root/src/Directory.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-09 13:14:14 +0100
committerMax Kellermann <max@duempel.org>2014-01-09 13:14:14 +0100
commit91efe1cb5ab4499512bf74b45221e800cc048726 (patch)
tree4dc541ed7085a0bbc2bd7c5b3bc43c458578f29f /src/Directory.hxx
parent735241f04922f9d666bf76dd003d2a6b03096f31 (diff)
downloadmpd-91efe1cb5ab4499512bf74b45221e800cc048726.tar.gz
mpd-91efe1cb5ab4499512bf74b45221e800cc048726.tar.xz
mpd-91efe1cb5ab4499512bf74b45221e800cc048726.zip
Directory: convert to fixed-size struct
Using a variable-size struct with embedded string is not worth the trouble here. There are not so many Directory objects.
Diffstat (limited to 'src/Directory.hxx')
-rw-r--r--src/Directory.hxx28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/Directory.hxx b/src/Directory.hxx
index 24ba685e6..a8e3e32cb 100644
--- a/src/Directory.hxx
+++ b/src/Directory.hxx
@@ -26,6 +26,8 @@
#include "DatabaseVisitor.hxx"
#include "PlaylistVector.hxx"
+#include <string>
+
#include <sys/types.h>
#define DEVICE_INARCHIVE (dev_t)(-1)
@@ -49,10 +51,6 @@ class SongFilter;
class Error;
struct Directory {
- template<class T, typename... Args> friend T *
- NewVarSize(size_t declared_tail_size, size_t real_tail_size,
- Args&&... args);
-
/**
* Pointers to the siblings of this directory within the
* parent directory. It is unused (undefined) in the root
@@ -86,36 +84,28 @@ struct Directory {
ino_t inode;
dev_t device;
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);
+ std::string path;
public:
+ Directory(const char *_path_utf8, Directory *_parent);
~Directory();
/**
- * Generic constructor for #Directory object.
- */
- gcc_malloc
- static Directory *NewGeneric(const char *path_utf8, Directory *parent);
-
- /**
* Create a new root #Directory object.
*/
gcc_malloc
static Directory *NewRoot() {
- return NewGeneric("", nullptr);
+ return new Directory("", nullptr);
}
/**
* Free this #Directory object (and the whole object tree within it),
* assuming it was already removed from the parent.
*/
- void Free();
+ void Free() {
+ delete this;
+ }
/**
* Remove this #Directory object from its parent and free it. This
@@ -178,7 +168,7 @@ public:
gcc_pure
const char *GetPath() const {
- return path;
+ return path.c_str();
}
/**