aboutsummaryrefslogtreecommitdiffstats
path: root/src/Directory.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-07 22:04:19 +0100
committerMax Kellermann <max@duempel.org>2014-01-07 23:10:56 +0100
commitda80f91e1c1a02abce17159ed303c7666d68bf14 (patch)
tree1aad9c825941f2e4e06b28e2e0f6a03e7e67b572 /src/Directory.cxx
parentcc60d193ce55b1fb8180bf199002bf34c2bf2088 (diff)
downloadmpd-da80f91e1c1a02abce17159ed303c7666d68bf14.tar.gz
mpd-da80f91e1c1a02abce17159ed303c7666d68bf14.tar.xz
mpd-da80f91e1c1a02abce17159ed303c7666d68bf14.zip
Directory: make some code generic, move to VarSize.hxx
Diffstat (limited to 'src/Directory.cxx')
-rw-r--r--src/Directory.cxx15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/Directory.cxx b/src/Directory.cxx
index 20fb44618..f9c1e2ba4 100644
--- a/src/Directory.cxx
+++ b/src/Directory.cxx
@@ -25,6 +25,7 @@
#include "SongSort.hxx"
#include "Song.hxx"
#include "fs/Traits.hxx"
+#include "util/VarSize.hxx"
#include "util/Error.hxx"
extern "C" {
@@ -42,14 +43,9 @@ Directory::Allocate(const char *path)
{
assert(path != nullptr);
- const size_t path_size = strlen(path) + 1;
- Directory *directory =
- (Directory *)g_malloc(sizeof(*directory)
- - sizeof(directory->path)
- + path_size);
- new(directory) Directory(path);
-
- return directory;
+ return NewVarSize<Directory>(sizeof(Directory::path),
+ strlen(path) + 1,
+ path);
}
Directory::Directory()
@@ -96,8 +92,7 @@ Directory::NewGeneric(const char *path, Directory *parent)
void
Directory::Free()
{
- this->Directory::~Directory();
- g_free(this);
+ DeleteVarSize(this);
}
void