db/simple/Song: add noexcept

This commit is contained in:
Max Kellermann 2019-05-21 22:41:21 +02:00
parent 8462559b2f
commit 0c48b8d084
2 changed files with 16 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@ -27,18 +27,20 @@
#include <assert.h>
#include <string.h>
inline Song::Song(const char *_uri, size_t uri_length, Directory &_parent)
inline
Song::Song(const char *_uri, size_t uri_length, Directory &_parent) noexcept
:parent(&_parent)
{
memcpy(uri, _uri, uri_length + 1);
}
inline Song::~Song()
inline
Song::~Song() noexcept
{
}
static Song *
song_alloc(const char *uri, Directory &parent)
song_alloc(const char *uri, Directory &parent) noexcept
{
size_t uri_length;
@ -52,7 +54,7 @@ song_alloc(const char *uri, Directory &parent)
}
Song *
Song::NewFrom(DetachedSong &&other, Directory &parent)
Song::NewFrom(DetachedSong &&other, Directory &parent) noexcept
{
Song *song = song_alloc(other.GetURI(), parent);
song->tag = std::move(other.WritableTag());
@ -63,13 +65,13 @@ Song::NewFrom(DetachedSong &&other, Directory &parent)
}
Song *
Song::NewFile(const char *path, Directory &parent)
Song::NewFile(const char *path, Directory &parent) noexcept
{
return song_alloc(path, parent);
}
void
Song::Free()
Song::Free() noexcept
{
DeleteVarSize(this);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@ -46,7 +46,7 @@ struct Song {
typedef boost::intrusive::list_member_hook<LinkMode> Hook;
struct Disposer {
void operator()(Song *song) const {
void operator()(Song *song) const noexcept {
song->Free();
}
};
@ -98,15 +98,15 @@ struct Song {
*/
char uri[sizeof(int)];
Song(const char *_uri, size_t uri_length, Directory &parent);
~Song();
Song(const char *_uri, size_t uri_length, Directory &parent) noexcept;
~Song() noexcept;
gcc_malloc gcc_returns_nonnull
static Song *NewFrom(DetachedSong &&other, Directory &parent);
static Song *NewFrom(DetachedSong &&other, Directory &parent) noexcept;
/** allocate a new song with a local file name */
gcc_malloc gcc_returns_nonnull
static Song *NewFile(const char *path_utf8, Directory &parent);
static Song *NewFile(const char *path_utf8, Directory &parent) noexcept;
/**
* allocate a new song structure with a local file name and attempt to
@ -117,7 +117,7 @@ struct Song {
static Song *LoadFile(Storage &storage, const char *name_utf8,
Directory &parent) noexcept;
void Free();
void Free() noexcept;
bool UpdateFile(Storage &storage) noexcept;