aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-25 18:47:21 +0100
committerMax Kellermann <max@duempel.org>2009-01-25 18:47:21 +0100
commita45922cd66cf8a7a03905c020e50ab01dc05cfa9 (patch)
tree2171f4d74886b9d049eafe14dc2b1ce72036c912
parent7960ad32fcfb1e17c24d3b26e53a1cdbc5ca0028 (diff)
downloadmpd-a45922cd66cf8a7a03905c020e50ab01dc05cfa9.tar.gz
mpd-a45922cd66cf8a7a03905c020e50ab01dc05cfa9.tar.xz
mpd-a45922cd66cf8a7a03905c020e50ab01dc05cfa9.zip
use g_free() instead of free()
On some platforms, g_free() must be used for memory allocated by GLib. This patch intends to correct a lot of occurrences, but is probably not complete.
-rw-r--r--src/audio.c2
-rw-r--r--src/client.c6
-rw-r--r--src/database.c2
-rw-r--r--src/dbUtils.c2
-rw-r--r--src/decoder/mikmod_plugin.c2
-rw-r--r--src/decoder/mp4_plugin.c4
-rw-r--r--src/directory.c4
-rw-r--r--src/locate.c6
-rw-r--r--src/output/alsa_plugin.c2
-rw-r--r--src/output/ao_plugin.c2
-rw-r--r--src/output/jack_plugin.c8
-rw-r--r--src/output/mvp_plugin.c2
-rw-r--r--src/output/oss_plugin.c2
-rw-r--r--src/output/osx_plugin.c5
-rw-r--r--src/output/shout_plugin.c2
-rw-r--r--src/strset.c4
-rw-r--r--src/tag.c14
-rw-r--r--src/update.c7
18 files changed, 36 insertions, 40 deletions
diff --git a/src/audio.c b/src/audio.c
index 854dc8a05..a4445ac54 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -183,7 +183,7 @@ void finishAudioDriver(void)
audio_output_finish(&audioOutputArray[i]);
}
- free(audioOutputArray);
+ g_free(audioOutputArray);
audioOutputArray = NULL;
audioOutputArraySize = 0;
diff --git a/src/client.c b/src/client.c
index 589e48c5d..1b08333bb 100644
--- a/src/client.c
+++ b/src/client.c
@@ -240,7 +240,7 @@ static void client_close(struct client *client)
g_log(G_LOG_DOMAIN, LOG_LEVEL_SECURE,
"client %i: closed", client->num);
- free(client);
+ g_free(client);
}
static const char *
@@ -637,7 +637,7 @@ static void client_write_deferred(struct client *client)
assert(client->deferred_bytes >= decr);
client->deferred_bytes -= decr;
- free(buf);
+ g_free(buf);
g_queue_pop_head(client->deferred_send);
}
client->lastTime = time(NULL);
@@ -778,7 +778,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args)
buffer = g_malloc(length + 1);
vsnprintf(buffer, length + 1, fmt, args);
client_write(client, buffer, length);
- free(buffer);
+ g_free(buffer);
}
G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...)
diff --git a/src/database.c b/src/database.c
index 6beb84f61..412163145 100644
--- a/src/database.c
+++ b/src/database.c
@@ -125,7 +125,7 @@ db_get_song(const char *file)
assert(song->parent == directory);
out:
- free(duplicated);
+ g_free(duplicated);
return song;
}
diff --git a/src/dbUtils.c b/src/dbUtils.c
index b33ec58df..a850bdba8 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -226,7 +226,7 @@ newListCommandItem(int tagType, const struct locate_item_list *criteria)
static void freeListCommandItem(ListCommandItem * item)
{
- free(item);
+ g_free(item);
}
static void
diff --git a/src/decoder/mikmod_plugin.c b/src/decoder/mikmod_plugin.c
index a22fd03bf..2fce23f7d 100644
--- a/src/decoder/mikmod_plugin.c
+++ b/src/decoder/mikmod_plugin.c
@@ -152,7 +152,7 @@ static void mod_close(mod_Data * data)
{
Player_Stop();
Player_Free(data->moduleHandle);
- free(data);
+ g_free(data);
}
static void
diff --git a/src/decoder/mp4_plugin.c b/src/decoder/mp4_plugin.c
index fd7415137..a85e8a710 100644
--- a/src/decoder/mp4_plugin.c
+++ b/src/decoder/mp4_plugin.c
@@ -179,7 +179,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
scale = mp4ff_time_scale(mp4fh, track);
- g_free(mp4_buffer);
+ free(mp4_buffer);
if (scale < 0) {
g_warning("Error getting audio format of mp4 AAC track.\n");
@@ -314,7 +314,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
file_time, bit_rate, NULL);
}
- free(seek_table);
+ g_free(seek_table);
faacDecClose(decoder);
mp4ff_close(mp4fh);
}
diff --git a/src/directory.c b/src/directory.c
index 8708e9095..cc7594747 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -54,7 +54,7 @@ directory_free(struct directory *directory)
dirvec_destroy(&directory->children);
songvec_destroy(&directory->songs);
- free(directory);
+ g_free(directory);
/* this resets last dir returned */
/*directory_get_path(NULL); */
}
@@ -108,7 +108,7 @@ directory_get_directory(struct directory *directory, const char *name)
locate = strchr(locate + 1, '/');
}
- free(duplicated);
+ g_free(duplicated);
return found;
}
diff --git a/src/locate.c b/src/locate.c
index 18d265490..55dad41c3 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -68,7 +68,7 @@ locate_item_new(const char *type_string, const char *needle)
struct locate_item *ret = g_new(struct locate_item, 1);
if (!locate_item_init(ret, type_string, needle)) {
- free(ret);
+ g_free(ret);
ret = NULL;
}
@@ -134,8 +134,8 @@ locate_item_list_casefold(const struct locate_item_list *list)
void
locate_item_free(struct locate_item *item)
{
- free(item->needle);
- free(item);
+ g_free(item->needle);
+ g_free(item);
}
static bool
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c
index 43ce99605..c26fcdf05 100644
--- a/src/output/alsa_plugin.c
+++ b/src/output/alsa_plugin.c
@@ -97,7 +97,7 @@ alsa_data_free(struct alsa_data *ad)
{
g_free(ad->device);
mixer_free(ad->mixer);
- free(ad);
+ g_free(ad);
}
static void
diff --git a/src/output/ao_plugin.c b/src/output/ao_plugin.c
index 10ce9c9de..655d267fd 100644
--- a/src/output/ao_plugin.c
+++ b/src/output/ao_plugin.c
@@ -131,7 +131,7 @@ audioOutputAo_initDriver(struct audio_output *ao,
static void freeAoData(AoData * ad)
{
ao_free_options(ad->options);
- free(ad);
+ g_free(ad);
}
static void audioOutputAo_finishDriver(void *data)
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index 8e4be218d..71957c226 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -92,7 +92,7 @@ mpd_jack_free(struct jack_data *jd)
for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i)
g_free(jd->output_ports[i]);
- free(jd);
+ g_free(jd);
}
static void
@@ -275,7 +275,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
jd->output_ports[0])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[0]);
- free(port_name);
+ g_free(port_name);
return -1;
}
sprintf(port_name, "%s:right", name);
@@ -283,10 +283,10 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
jd->output_ports[1])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[1]);
- free(port_name);
+ g_free(port_name);
return -1;
}
- free(port_name);
+ g_free(port_name);
}
return 1;
diff --git a/src/output/mvp_plugin.c b/src/output/mvp_plugin.c
index cf63faf08..7eccb23a2 100644
--- a/src/output/mvp_plugin.c
+++ b/src/output/mvp_plugin.c
@@ -124,7 +124,7 @@ static void *mvp_initDriver(G_GNUC_UNUSED struct audio_output *audio_output,
static void mvp_finishDriver(void *data)
{
MvpData *md = data;
- free(md);
+ g_free(md);
}
static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c
index 33587be2c..c4b4698ee 100644
--- a/src/output/oss_plugin.c
+++ b/src/output/oss_plugin.c
@@ -292,7 +292,7 @@ static void freeOssData(OssData * od)
mixer_free(od->mixer);
- free(od);
+ g_free(od);
}
#define OSS_STAT_NO_ERROR 0
diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c
index 44a87f9d3..2ab0d6b0d 100644
--- a/src/output/osx_plugin.c
+++ b/src/output/osx_plugin.c
@@ -90,11 +90,10 @@ osx_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
static void freeOsxData(OsxData * od)
{
- if (od->buffer)
- free(od->buffer);
+ g_free(od->buffer);
g_mutex_free(od->mutex);
g_cond_free(od->condition);
- free(od);
+ g_free(od);
}
static void osx_finishDriver(void *data)
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index 2217bc56e..3fc372250 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -81,7 +81,7 @@ static void free_shout_data(struct shout_data *sd)
if (sd->timer)
timer_free(sd->timer);
- free(sd);
+ g_free(sd);
}
#define check_block_param(name) { \
diff --git a/src/strset.c b/src/strset.c
index c5c3031b9..0eb63bcbb 100644
--- a/src/strset.c
+++ b/src/strset.c
@@ -64,12 +64,12 @@ void strset_free(struct strset *set)
while (slot != NULL) {
next = slot->next;
- free(slot);
+ g_free(slot);
slot = next;
}
}
- free(set);
+ g_free(set);
}
void strset_add(struct strset *set, const char *value)
diff --git a/src/tag.c b/src/tag.c
index 8ac070614..23355c725 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -115,7 +115,7 @@ void tag_lib_init(void)
s++;
}
- free(temp);
+ g_free(temp);
}
struct tag *tag_ape_load(const char *file)
@@ -234,8 +234,7 @@ struct tag *tag_ape_load(const char *file)
fail:
if (fp)
fclose(fp);
- if (buffer)
- free(buffer);
+ g_free(buffer);
return ret;
}
@@ -265,7 +264,7 @@ static void deleteItem(struct tag *tag, int idx)
if (tag->numOfItems > 0) {
tag->items = g_realloc(tag->items, items_size(tag));
} else {
- free(tag->items);
+ g_free(tag->items);
tag->items = NULL;
}
}
@@ -297,11 +296,10 @@ void tag_free(struct tag *tag)
assert(bulk.busy);
bulk.busy = 0;
#endif
- } else if (tag->items) {
- free(tag->items);
- }
+ } else
+ g_free(tag->items);
- free(tag);
+ g_free(tag);
}
struct tag *tag_dup(const struct tag *tag)
diff --git a/src/update.c b/src/update.c
index 4316dd727..c8e328403 100644
--- a/src/update.c
+++ b/src/update.c
@@ -618,7 +618,7 @@ addParentPathToDB(const char *utf8path)
*slash++ = '/';
}
- free(duplicated);
+ g_free(duplicated);
return directory;
}
@@ -647,7 +647,7 @@ static void * update_task(void *_path)
{
if (_path != NULL && !isRootDirectory(_path)) {
updatePath((char *)_path);
- free(_path);
+ g_free(_path);
} else {
struct directory *directory = db_get_root();
struct stat st;
@@ -691,8 +691,7 @@ directory_update_init(char *path)
unsigned next_task_id;
if (update_paths_nr == G_N_ELEMENTS(update_paths)) {
- if (path)
- free(path);
+ g_free(path);
return 0;
}