Commit 0c48b8d0 authored by Max Kellermann's avatar Max Kellermann

db/simple/Song: add `noexcept`

parent 8462559b
/* /*
* Copyright 2003-2018 The Music Player Daemon Project * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -27,18 +27,20 @@ ...@@ -27,18 +27,20 @@
#include <assert.h> #include <assert.h>
#include <string.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) :parent(&_parent)
{ {
memcpy(uri, _uri, uri_length + 1); memcpy(uri, _uri, uri_length + 1);
} }
inline Song::~Song() inline
Song::~Song() noexcept
{ {
} }
static Song * static Song *
song_alloc(const char *uri, Directory &parent) song_alloc(const char *uri, Directory &parent) noexcept
{ {
size_t uri_length; size_t uri_length;
...@@ -52,7 +54,7 @@ song_alloc(const char *uri, Directory &parent) ...@@ -52,7 +54,7 @@ song_alloc(const char *uri, Directory &parent)
} }
Song * Song *
Song::NewFrom(DetachedSong &&other, Directory &parent) Song::NewFrom(DetachedSong &&other, Directory &parent) noexcept
{ {
Song *song = song_alloc(other.GetURI(), parent); Song *song = song_alloc(other.GetURI(), parent);
song->tag = std::move(other.WritableTag()); song->tag = std::move(other.WritableTag());
...@@ -63,13 +65,13 @@ Song::NewFrom(DetachedSong &&other, Directory &parent) ...@@ -63,13 +65,13 @@ Song::NewFrom(DetachedSong &&other, Directory &parent)
} }
Song * Song *
Song::NewFile(const char *path, Directory &parent) Song::NewFile(const char *path, Directory &parent) noexcept
{ {
return song_alloc(path, parent); return song_alloc(path, parent);
} }
void void
Song::Free() Song::Free() noexcept
{ {
DeleteVarSize(this); DeleteVarSize(this);
} }
......
/* /*
* Copyright 2003-2018 The Music Player Daemon Project * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -46,7 +46,7 @@ struct Song { ...@@ -46,7 +46,7 @@ struct Song {
typedef boost::intrusive::list_member_hook<LinkMode> Hook; typedef boost::intrusive::list_member_hook<LinkMode> Hook;
struct Disposer { struct Disposer {
void operator()(Song *song) const { void operator()(Song *song) const noexcept {
song->Free(); song->Free();
} }
}; };
...@@ -98,15 +98,15 @@ struct Song { ...@@ -98,15 +98,15 @@ struct Song {
*/ */
char uri[sizeof(int)]; char uri[sizeof(int)];
Song(const char *_uri, size_t uri_length, Directory &parent); Song(const char *_uri, size_t uri_length, Directory &parent) noexcept;
~Song(); ~Song() noexcept;
gcc_malloc gcc_returns_nonnull 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 */ /** allocate a new song with a local file name */
gcc_malloc gcc_returns_nonnull 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 * allocate a new song structure with a local file name and attempt to
...@@ -117,7 +117,7 @@ struct Song { ...@@ -117,7 +117,7 @@ struct Song {
static Song *LoadFile(Storage &storage, const char *name_utf8, static Song *LoadFile(Storage &storage, const char *name_utf8,
Directory &parent) noexcept; Directory &parent) noexcept;
void Free(); void Free() noexcept;
bool UpdateFile(Storage &storage) noexcept; bool UpdateFile(Storage &storage) noexcept;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment