diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DirectorySave.cxx | 2 | ||||
-rw-r--r-- | src/Song.cxx | 12 | ||||
-rw-r--r-- | src/Song.hxx | 14 | ||||
-rw-r--r-- | src/SongUpdate.cxx | 5 | ||||
-rw-r--r-- | src/UpdateContainer.cxx | 2 | ||||
-rw-r--r-- | src/UpdateSong.cxx | 2 |
6 files changed, 16 insertions, 21 deletions
diff --git a/src/DirectorySave.cxx b/src/DirectorySave.cxx index 1072b1e28..499f84734 100644 --- a/src/DirectorySave.cxx +++ b/src/DirectorySave.cxx @@ -145,7 +145,7 @@ directory_load(TextFile &file, Directory &directory, Error &error) return false; directory.AddSong(Song::NewFrom(std::move(*song), - &directory)); + directory)); delete song; } else if (StringStartsWith(line, PLAYLIST_META_BEGIN)) { const char *name = line + sizeof(PLAYLIST_META_BEGIN) - 1; diff --git a/src/Song.cxx b/src/Song.cxx index 565b9af98..15924a40a 100644 --- a/src/Song.cxx +++ b/src/Song.cxx @@ -29,8 +29,8 @@ #include <string.h> #include <stdlib.h> -inline Song::Song(const char *_uri, size_t uri_length, Directory *_parent) - :parent(_parent), mtime(0), start_ms(0), end_ms(0) +inline Song::Song(const char *_uri, size_t uri_length, Directory &_parent) + :parent(&_parent), mtime(0), start_ms(0), end_ms(0) { memcpy(uri, _uri, uri_length + 1); } @@ -40,7 +40,7 @@ inline Song::~Song() } static Song * -song_alloc(const char *uri, Directory *parent) +song_alloc(const char *uri, Directory &parent) { size_t uri_length; @@ -54,7 +54,7 @@ song_alloc(const char *uri, Directory *parent) } Song * -Song::NewFrom(DetachedSong &&other, Directory *parent) +Song::NewFrom(DetachedSong &&other, Directory &parent) { Song *song = song_alloc(other.GetURI(), parent); song->tag = std::move(other.WritableTag()); @@ -65,7 +65,7 @@ Song::NewFrom(DetachedSong &&other, Directory *parent) } Song * -Song::NewFile(const char *path, Directory *parent) +Song::NewFile(const char *path, Directory &parent) { return song_alloc(path, parent); } @@ -81,7 +81,7 @@ Song::GetURI() const { assert(*uri); - if (parent == nullptr || parent->IsRoot()) + if (parent->IsRoot()) return std::string(uri); else { const char *path = parent->GetPath(); diff --git a/src/Song.hxx b/src/Song.hxx index 824fb429c..0b94fe6d0 100644 --- a/src/Song.hxx +++ b/src/Song.hxx @@ -54,7 +54,7 @@ struct Song { * the current database plugin does not manage the parent * directory this way. */ - Directory *parent; + Directory *const parent; time_t mtime; @@ -75,15 +75,15 @@ struct Song { */ char uri[sizeof(int)]; - Song(const char *_uri, size_t uri_length, Directory *parent); + Song(const char *_uri, size_t uri_length, Directory &parent); ~Song(); gcc_malloc - static Song *NewFrom(DetachedSong &&other, Directory *parent); + static Song *NewFrom(DetachedSong &&other, Directory &parent); /** allocate a new song with a local file name */ gcc_malloc - static Song *NewFile(const char *path_utf8, Directory *parent); + static Song *NewFile(const char *path_utf8, Directory &parent); /** * allocate a new song structure with a local file name and attempt to @@ -91,11 +91,7 @@ struct Song { * data, nullptr is returned. */ gcc_malloc - static Song *LoadFile(const char *path_utf8, Directory *parent); - - static Song *LoadFile(const char *path_utf8, Directory &parent) { - return LoadFile(path_utf8, &parent); - } + static Song *LoadFile(const char *path_utf8, Directory &parent); void Free(); diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index dd01ea7d7..ee70085f3 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -40,19 +40,18 @@ #include <sys/stat.h> Song * -Song::LoadFile(const char *path_utf8, Directory *parent) +Song::LoadFile(const char *path_utf8, Directory &parent) { Song *song; bool ret; - assert((parent == nullptr) == PathTraitsUTF8::IsAbsolute(path_utf8)); assert(!uri_has_scheme(path_utf8)); assert(strchr(path_utf8, '\n') == nullptr); song = NewFile(path_utf8, parent); //in archive ? - if (parent != nullptr && parent->device == DEVICE_INARCHIVE) { + if (parent.device == DEVICE_INARCHIVE) { ret = song->UpdateFileInArchive(); } else { ret = song->UpdateFile(); diff --git a/src/UpdateContainer.cxx b/src/UpdateContainer.cxx index 635006344..2323f69f6 100644 --- a/src/UpdateContainer.cxx +++ b/src/UpdateContainer.cxx @@ -102,7 +102,7 @@ update_container_file(Directory &directory, unsigned int tnum = 0; TagBuilder tag_builder; while ((vtrack = plugin.container_scan(pathname.c_str(), ++tnum)) != nullptr) { - Song *song = Song::NewFile(vtrack, contdir); + Song *song = Song::NewFile(vtrack, *contdir); // shouldn't be necessary but it's there.. song->mtime = st->st_mtime; diff --git a/src/UpdateSong.cxx b/src/UpdateSong.cxx index d07948eed..592298f49 100644 --- a/src/UpdateSong.cxx +++ b/src/UpdateSong.cxx @@ -69,7 +69,7 @@ update_song_file2(Directory &directory, if (song == nullptr) { FormatDebug(update_domain, "reading %s/%s", directory.GetPath(), name); - song = Song::LoadFile(name, &directory); + song = Song::LoadFile(name, directory); if (song == nullptr) { FormatDebug(update_domain, "ignoring unrecognized file %s/%s", |