diff options
author | Kalle Wallin <kaw@linux.se> | 2004-03-28 21:27:11 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-03-28 21:27:11 +0000 |
commit | 8a7c44223cbea87ef27a2f9f876a2cdaba8abec3 (patch) | |
tree | 18b79715c5c40be941496cfd0758ce7341da5f30 /mpc.c | |
parent | e77407bf104d05c537f8f556ad9702ea98224d3c (diff) | |
download | mpd-8a7c44223cbea87ef27a2f9f876a2cdaba8abec3.tar.gz mpd-8a7c44223cbea87ef27a2f9f876a2cdaba8abec3.tar.xz mpd-8a7c44223cbea87ef27a2f9f876a2cdaba8abec3.zip |
We now allocate and free memory with glib
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@526 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'mpc.c')
-rw-r--r-- | mpc.c | 23 |
1 files changed, 9 insertions, 14 deletions
@@ -1,8 +1,3 @@ -/* - * $Id: mpc.c,v 1.5 2004/03/17 23:19:21 kalle Exp $ - * - */ - #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -62,7 +57,7 @@ mpc_close(mpd_client_t *c) if( c->connection ) mpd_closeConnection(c->connection); if( c->cwd ) - free( c->cwd ); + g_free( c->cwd ); return 0; } @@ -80,10 +75,10 @@ mpc_connect(char *host, int port) exit(EXIT_FAILURE); } - c = malloc(sizeof(mpd_client_t)); + c = g_malloc(sizeof(mpd_client_t)); memset(c, 0, sizeof(mpd_client_t)); c->connection = connection; - c->cwd = strdup(""); + c->cwd = g_strdup(""); return c; } @@ -228,20 +223,20 @@ mpc_get_song_name(mpd_Song *song) snprintf(buf, MAX_SONG_LENGTH, "%s - %s", song->artist, song->title); name = utf8_to_locale(buf); strncpy(buf, name, MAX_SONG_LENGTH); - free(name); + g_free(name); return buf; } else { name = utf8_to_locale(song->title); strncpy(buf, name, MAX_SONG_LENGTH); - free(name); + g_free(name); return buf; } } name = utf8_to_locale(basename(song->file)); strncpy(buf, name, MAX_SONG_LENGTH); - free(name); + g_free(name); return buf; } @@ -294,7 +289,7 @@ mpc_free_filelist(mpd_client_t *c) if( entry->entity ) mpd_freeInfoEntity(entry->entity); - free(entry); + g_free(entry); list=list->next; } g_list_free(c->filelist); @@ -325,7 +320,7 @@ mpc_update_filelist(mpd_client_t *c) if( c->cwd && c->cwd[0] ) { /* add a dummy entry for ./.. */ - filelist_entry_t *entry = malloc(sizeof(filelist_entry_t)); + filelist_entry_t *entry = g_malloc(sizeof(filelist_entry_t)); memset(entry, 0, sizeof(filelist_entry_t)); entry->entity = NULL; c->filelist = g_list_append(c->filelist, (gpointer) entry); @@ -334,7 +329,7 @@ mpc_update_filelist(mpd_client_t *c) while( (entity=mpd_getNextInfoEntity(c->connection)) ) { - filelist_entry_t *entry = malloc(sizeof(filelist_entry_t)); + filelist_entry_t *entry = g_malloc(sizeof(filelist_entry_t)); memset(entry, 0, sizeof(filelist_entry_t)); entry->entity = entity; |