throw away all NULLs and replace them by 0s

This commit is contained in:
Andrzej Rybczak
2009-08-30 17:43:13 +02:00
parent 0a22debf0e
commit 6843b98627
5 changed files with 23 additions and 35 deletions

View File

@@ -80,7 +80,7 @@ void Info::Update()
if (!ArtistReady) if (!ArtistReady)
return; return;
pthread_join(*Downloader, NULL); pthread_join(*Downloader, 0);
w->Flush(); w->Flush();
delete Downloader; delete Downloader;
Downloader = 0; Downloader = 0;

View File

@@ -306,7 +306,7 @@ void Lyrics::Take()
{ {
if (!Ready) if (!Ready)
return; return;
pthread_join(*Downloader, NULL); pthread_join(*Downloader, 0);
w->Flush(); w->Flush();
delete Downloader; delete Downloader;
Downloader = 0; Downloader = 0;

View File

@@ -391,8 +391,7 @@ void Connection::GetPlaylistChanges(long long id, SongList &v) const
v.reserve(GetPlaylistLength()); v.reserve(GetPlaylistLength());
} }
mpd_sendPlChangesCommand(itsConnection, id); mpd_sendPlChangesCommand(itsConnection, id);
mpd_InfoEntity *item = NULL; while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL)
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_SONG) if (item->type == MPD_INFO_ENTITY_TYPE_SONG)
{ {
@@ -411,8 +410,7 @@ Song Connection::GetSong(const std::string &path) const
if (isConnected) if (isConnected)
{ {
mpd_sendListallInfoCommand(itsConnection, path.c_str()); mpd_sendListallInfoCommand(itsConnection, path.c_str());
mpd_InfoEntity *item = NULL; mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection);
item = mpd_getNextInfoEntity(itsConnection);
Song result = item->info.song; Song result = item->info.song;
item->info.song = 0; item->info.song = 0;
mpd_freeInfoEntity(item); mpd_freeInfoEntity(item);
@@ -433,9 +431,7 @@ Song Connection::GetCurrentSong() const
if (isConnected && (GetState() == psPlay || GetState() == psPause)) if (isConnected && (GetState() == psPlay || GetState() == psPause))
{ {
mpd_sendCurrentSongCommand(itsConnection); mpd_sendCurrentSongCommand(itsConnection);
mpd_InfoEntity *item = NULL; if (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
item = mpd_getNextInfoEntity(itsConnection);
if (item)
{ {
Song result = item->info.song; Song result = item->info.song;
item->info.song = 0; item->info.song = 0;
@@ -455,8 +451,7 @@ void Connection::GetPlaylistContent(const std::string &path, SongList &v) const
if (isConnected) if (isConnected)
{ {
mpd_sendListPlaylistInfoCommand(itsConnection, path.c_str()); mpd_sendListPlaylistInfoCommand(itsConnection, path.c_str());
mpd_InfoEntity *item = NULL; while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL)
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_SONG) if (item->type == MPD_INFO_ENTITY_TYPE_SONG)
{ {
@@ -553,7 +548,7 @@ int Connection::AddSong(const std::string &path)
id = 0; id = 0;
} }
else if (itsErrorHandler) else if (itsErrorHandler)
itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, NULL); itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, itsErrorHandlerUserdata);
} }
return id; return id;
} }
@@ -653,7 +648,7 @@ bool Connection::CommitCommandsList()
mpd_finishCommand(itsConnection); mpd_finishCommand(itsConnection);
UpdateStatus(); UpdateStatus();
if (GetPlaylistLength() == itsMaxPlaylistLength && itsErrorHandler) if (GetPlaylistLength() == itsMaxPlaylistLength && itsErrorHandler)
itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, NULL); itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, itsErrorHandlerUserdata);
isCommandsListEnabled = 0; isCommandsListEnabled = 0;
} }
return !CheckForErrors(); return !CheckForErrors();
@@ -700,9 +695,8 @@ void Connection::GetList(TagList &v, mpd_TagItems type) const
{ {
if (isConnected) if (isConnected)
{ {
mpd_sendListCommand(itsConnection, type, NULL); mpd_sendListCommand(itsConnection, type, 0);
char *item; while (char *item = mpd_getNextTag(itsConnection, type))
while ((item = mpd_getNextTag(itsConnection, type)) != NULL)
{ {
if (item[0] != 0) // do not push empty item if (item[0] != 0) // do not push empty item
v.push_back(item); v.push_back(item);
@@ -716,9 +710,9 @@ void Connection::GetAlbums(const std::string &artist, TagList &v) const
{ {
if (isConnected) if (isConnected)
{ {
mpd_sendListCommand(itsConnection, MPD_TABLE_ALBUM, artist.empty() ? NULL : artist.c_str()); mpd_sendListCommand(itsConnection, MPD_TABLE_ALBUM, artist.empty() ? 0 : artist.c_str());
char *item;
while ((item = mpd_getNextAlbum(itsConnection)) != NULL) while (char *item = mpd_getNextAlbum(itsConnection))
{ {
if (item[0] != 0) // do not push empty item if (item[0] != 0) // do not push empty item
v.push_back(item); v.push_back(item);
@@ -757,8 +751,7 @@ void Connection::CommitSearch(SongList &v) const
if (isConnected) if (isConnected)
{ {
mpd_commitSearch(itsConnection); mpd_commitSearch(itsConnection);
mpd_InfoEntity *item = NULL; while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL)
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_SONG) if (item->type == MPD_INFO_ENTITY_TYPE_SONG)
{ {
@@ -777,8 +770,7 @@ void Connection::CommitSearch(TagList &v) const
if (isConnected) if (isConnected)
{ {
mpd_commitSearch(itsConnection); mpd_commitSearch(itsConnection);
char *tag = NULL; while (char *tag = mpd_getNextTag(itsConnection, itsSearchedField))
while ((tag = mpd_getNextTag(itsConnection, itsSearchedField)) != NULL)
{ {
if (tag[0] != 0) // do not push empty item if (tag[0] != 0) // do not push empty item
v.push_back(tag); v.push_back(tag);
@@ -792,9 +784,8 @@ void Connection::GetDirectory(const std::string &path, ItemList &v) const
{ {
if (isConnected) if (isConnected)
{ {
mpd_InfoEntity *item = NULL;
mpd_sendLsInfoCommand(itsConnection, path.c_str()); mpd_sendLsInfoCommand(itsConnection, path.c_str());
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL) while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
{ {
Item i; Item i;
switch (item->type) switch (item->type)
@@ -824,9 +815,8 @@ void Connection::GetDirectoryRecursive(const std::string &path, SongList &v) con
{ {
if (isConnected) if (isConnected)
{ {
mpd_InfoEntity *item = NULL;
mpd_sendListallInfoCommand(itsConnection, path.c_str()); mpd_sendListallInfoCommand(itsConnection, path.c_str());
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL) while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_SONG) if (item->type == MPD_INFO_ENTITY_TYPE_SONG)
{ {
@@ -844,9 +834,8 @@ void Connection::GetSongs(const std::string &path, SongList &v) const
{ {
if (isConnected) if (isConnected)
{ {
mpd_InfoEntity *item = NULL;
mpd_sendLsInfoCommand(itsConnection, path.c_str()); mpd_sendLsInfoCommand(itsConnection, path.c_str());
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL) while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_SONG) if (item->type == MPD_INFO_ENTITY_TYPE_SONG)
{ {
@@ -864,9 +853,8 @@ void Connection::GetDirectories(const std::string &path, TagList &v) const
{ {
if (isConnected) if (isConnected)
{ {
mpd_InfoEntity *item = NULL;
mpd_sendLsInfoCommand(itsConnection, path.c_str()); mpd_sendLsInfoCommand(itsConnection, path.c_str());
while ((item = mpd_getNextInfoEntity(itsConnection)) != NULL) while (mpd_InfoEntity *item = mpd_getNextInfoEntity(itsConnection))
{ {
if (item->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) if (item->type == MPD_INFO_ENTITY_TYPE_DIRECTORY)
v.push_back(item->info.directory->path); v.push_back(item->info.directory->path);

View File

@@ -162,8 +162,8 @@ int main(int argc, char *argv[])
myPlaylist->SwitchTo(); myPlaylist->SwitchTo();
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
Mpd.SetStatusUpdater(NcmpcppStatusChanged, NULL); Mpd.SetStatusUpdater(NcmpcppStatusChanged, 0);
Mpd.SetErrorHandler(NcmpcppErrorCallback, NULL); Mpd.SetErrorHandler(NcmpcppErrorCallback, 0);
// local variables // local variables
int input; int input;
@@ -1105,7 +1105,7 @@ int main(int argc, char *argv[])
LockStatusbar(); LockStatusbar();
int songpos; int songpos;
time_t t = time(NULL); time_t t = time(0);
songpos = Mpd.GetElapsedTime(); songpos = Mpd.GetElapsedTime();

View File

@@ -158,7 +158,7 @@ void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
{ {
if (errorid == MPD_ACK_ERROR_PERMISSION) if (errorid == MPD_ACK_ERROR_PERMISSION)
{ {
wFooter->SetGetStringHelper(NULL); wFooter->SetGetStringHelper(0);
Statusbar() << "Password: "; Statusbar() << "Password: ";
std::string password = wFooter->GetString(-1, 0, 1); std::string password = wFooter->GetString(-1, 0, 1);
Mpd.SetPassword(password); Mpd.SetPassword(password);