Free memory
This commit is contained in:
parent
b0450da800
commit
4ff070b731
@ -228,3 +228,10 @@ bool dbusPlaying( DBusConnection *conn, const char *player ) {
|
|||||||
free( status );
|
free( status );
|
||||||
return ret;
|
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 );
|
void dbusStop( DBusConnection *conn, const char *player );
|
||||||
bool dbusRunning( DBusConnection *conn, const char *player );
|
bool dbusRunning( DBusConnection *conn, const char *player );
|
||||||
bool dbusPlaying( DBusConnection *conn, const char *player );
|
bool dbusPlaying( DBusConnection *conn, const char *player );
|
||||||
|
void dbusFreePlyaers( char **dbus_players );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
main.c
11
main.c
@ -79,6 +79,7 @@ int main( int argc, char **argv ) {
|
|||||||
printMeta( &song );
|
printMeta( &song );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
freeSong( &song );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( requests & RUNNING_FLAG ) {
|
if( requests & RUNNING_FLAG ) {
|
||||||
@ -121,9 +122,13 @@ int main( int argc, char **argv ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free( dbus_players );
|
if( sources & DBUS_FLAG ) {
|
||||||
dbusDisconnect( dbus_connection );
|
dbusFreePlyaers( dbus_players );
|
||||||
mpdDisconnect( mpd_connection );
|
dbusDisconnect( dbus_connection );
|
||||||
|
}
|
||||||
|
if( sources & MPD_FLAG ) {
|
||||||
|
mpdDisconnect( mpd_connection );
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
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 );
|
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 printSong( struct song_metadata *song );
|
||||||
void printMeta( struct song_metadata *song );
|
void printMeta( struct song_metadata *song );
|
||||||
|
void freeSong( struct song_metadata *song );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user