Free memory
This commit is contained in:
parent
b0450da800
commit
4ff070b731
@ -228,3 +228,10 @@ bool dbusPlaying( DBusConnection *conn, const char *player ) {
|
||||
free( status );
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dbusFreePlyaers( char **dbus_players ) {
|
||||
for( char **player = dbus_players; *player; ++player ) {
|
||||
free( *player );
|
||||
}
|
||||
free( dbus_players );
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ void dbusPrev( DBusConnection *conn, const char *player );
|
||||
void dbusStop( DBusConnection *conn, const char *player );
|
||||
bool dbusRunning( DBusConnection *conn, const char *player );
|
||||
bool dbusPlaying( DBusConnection *conn, const char *player );
|
||||
void dbusFreePlyaers( char **dbus_players );
|
||||
|
||||
#endif
|
||||
|
11
main.c
11
main.c
@ -79,6 +79,7 @@ int main( int argc, char **argv ) {
|
||||
printMeta( &song );
|
||||
}
|
||||
}
|
||||
freeSong( &song );
|
||||
}
|
||||
|
||||
if( requests & RUNNING_FLAG ) {
|
||||
@ -121,9 +122,13 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
}
|
||||
|
||||
free( dbus_players );
|
||||
dbusDisconnect( dbus_connection );
|
||||
mpdDisconnect( mpd_connection );
|
||||
if( sources & DBUS_FLAG ) {
|
||||
dbusFreePlyaers( dbus_players );
|
||||
dbusDisconnect( dbus_connection );
|
||||
}
|
||||
if( sources & MPD_FLAG ) {
|
||||
mpdDisconnect( mpd_connection );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
15
metadata.c
15
metadata.c
@ -22,3 +22,18 @@ void printMeta( struct song_metadata *song ) {
|
||||
printf( "ART: %s\n", song->art_uri );
|
||||
}
|
||||
}
|
||||
|
||||
void freeSong( struct song_metadata *song ) {
|
||||
free( (void*)song->art_uri );
|
||||
song->art_uri = NULL;
|
||||
free( (void*)song->file );
|
||||
song->file = NULL;
|
||||
free( (void*)song->year );
|
||||
song->year = NULL;
|
||||
free( (void*)song->artist );
|
||||
song->artist = NULL;
|
||||
free( (void*)song->album );
|
||||
song->album = NULL;
|
||||
free( (void*)song->title );
|
||||
song->title = NULL;
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ struct song_metadata {
|
||||
|
||||
void printSong( struct song_metadata *song );
|
||||
void printMeta( struct song_metadata *song );
|
||||
void freeSong( struct song_metadata *song );
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user