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.
This commit is contained in:
Max Kellermann 2009-01-25 18:47:21 +01:00
parent 7960ad32fc
commit a45922cd66
18 changed files with 36 additions and 40 deletions

View File

@ -183,7 +183,7 @@ void finishAudioDriver(void)
audio_output_finish(&audioOutputArray[i]); audio_output_finish(&audioOutputArray[i]);
} }
free(audioOutputArray); g_free(audioOutputArray);
audioOutputArray = NULL; audioOutputArray = NULL;
audioOutputArraySize = 0; audioOutputArraySize = 0;

View File

@ -240,7 +240,7 @@ static void client_close(struct client *client)
g_log(G_LOG_DOMAIN, LOG_LEVEL_SECURE, g_log(G_LOG_DOMAIN, LOG_LEVEL_SECURE,
"client %i: closed", client->num); "client %i: closed", client->num);
free(client); g_free(client);
} }
static const char * static const char *
@ -637,7 +637,7 @@ static void client_write_deferred(struct client *client)
assert(client->deferred_bytes >= decr); assert(client->deferred_bytes >= decr);
client->deferred_bytes -= decr; client->deferred_bytes -= decr;
free(buf); g_free(buf);
g_queue_pop_head(client->deferred_send); g_queue_pop_head(client->deferred_send);
} }
client->lastTime = time(NULL); 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); buffer = g_malloc(length + 1);
vsnprintf(buffer, length + 1, fmt, args); vsnprintf(buffer, length + 1, fmt, args);
client_write(client, buffer, length); client_write(client, buffer, length);
free(buffer); g_free(buffer);
} }
G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...) G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...)

View File

@ -125,7 +125,7 @@ db_get_song(const char *file)
assert(song->parent == directory); assert(song->parent == directory);
out: out:
free(duplicated); g_free(duplicated);
return song; return song;
} }

View File

@ -226,7 +226,7 @@ newListCommandItem(int tagType, const struct locate_item_list *criteria)
static void freeListCommandItem(ListCommandItem * item) static void freeListCommandItem(ListCommandItem * item)
{ {
free(item); g_free(item);
} }
static void static void

View File

@ -152,7 +152,7 @@ static void mod_close(mod_Data * data)
{ {
Player_Stop(); Player_Stop();
Player_Free(data->moduleHandle); Player_Free(data->moduleHandle);
free(data); g_free(data);
} }
static void static void

View File

@ -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); file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
scale = mp4ff_time_scale(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track);
g_free(mp4_buffer); free(mp4_buffer);
if (scale < 0) { if (scale < 0) {
g_warning("Error getting audio format of mp4 AAC track.\n"); 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); file_time, bit_rate, NULL);
} }
free(seek_table); g_free(seek_table);
faacDecClose(decoder); faacDecClose(decoder);
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
} }

View File

@ -54,7 +54,7 @@ directory_free(struct directory *directory)
dirvec_destroy(&directory->children); dirvec_destroy(&directory->children);
songvec_destroy(&directory->songs); songvec_destroy(&directory->songs);
free(directory); g_free(directory);
/* this resets last dir returned */ /* this resets last dir returned */
/*directory_get_path(NULL); */ /*directory_get_path(NULL); */
} }
@ -108,7 +108,7 @@ directory_get_directory(struct directory *directory, const char *name)
locate = strchr(locate + 1, '/'); locate = strchr(locate + 1, '/');
} }
free(duplicated); g_free(duplicated);
return found; return found;
} }

View File

@ -68,7 +68,7 @@ locate_item_new(const char *type_string, const char *needle)
struct locate_item *ret = g_new(struct locate_item, 1); struct locate_item *ret = g_new(struct locate_item, 1);
if (!locate_item_init(ret, type_string, needle)) { if (!locate_item_init(ret, type_string, needle)) {
free(ret); g_free(ret);
ret = NULL; ret = NULL;
} }
@ -134,8 +134,8 @@ locate_item_list_casefold(const struct locate_item_list *list)
void void
locate_item_free(struct locate_item *item) locate_item_free(struct locate_item *item)
{ {
free(item->needle); g_free(item->needle);
free(item); g_free(item);
} }
static bool static bool

View File

@ -97,7 +97,7 @@ alsa_data_free(struct alsa_data *ad)
{ {
g_free(ad->device); g_free(ad->device);
mixer_free(ad->mixer); mixer_free(ad->mixer);
free(ad); g_free(ad);
} }
static void static void

View File

@ -131,7 +131,7 @@ audioOutputAo_initDriver(struct audio_output *ao,
static void freeAoData(AoData * ad) static void freeAoData(AoData * ad)
{ {
ao_free_options(ad->options); ao_free_options(ad->options);
free(ad); g_free(ad);
} }
static void audioOutputAo_finishDriver(void *data) static void audioOutputAo_finishDriver(void *data)

View File

@ -92,7 +92,7 @@ mpd_jack_free(struct jack_data *jd)
for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i) for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i)
g_free(jd->output_ports[i]); g_free(jd->output_ports[i]);
free(jd); g_free(jd);
} }
static void static void
@ -275,7 +275,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
jd->output_ports[0])) != 0 ) { jd->output_ports[0])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port", g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[0]); jd->output_ports[0]);
free(port_name); g_free(port_name);
return -1; return -1;
} }
sprintf(port_name, "%s:right", name); 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 ) { jd->output_ports[1])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port", g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[1]); jd->output_ports[1]);
free(port_name); g_free(port_name);
return -1; return -1;
} }
free(port_name); g_free(port_name);
} }
return 1; return 1;

View File

@ -124,7 +124,7 @@ static void *mvp_initDriver(G_GNUC_UNUSED struct audio_output *audio_output,
static void mvp_finishDriver(void *data) static void mvp_finishDriver(void *data)
{ {
MvpData *md = data; MvpData *md = data;
free(md); g_free(md);
} }
static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels, static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,

View File

@ -292,7 +292,7 @@ static void freeOssData(OssData * od)
mixer_free(od->mixer); mixer_free(od->mixer);
free(od); g_free(od);
} }
#define OSS_STAT_NO_ERROR 0 #define OSS_STAT_NO_ERROR 0

View File

@ -90,11 +90,10 @@ osx_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
static void freeOsxData(OsxData * od) static void freeOsxData(OsxData * od)
{ {
if (od->buffer) g_free(od->buffer);
free(od->buffer);
g_mutex_free(od->mutex); g_mutex_free(od->mutex);
g_cond_free(od->condition); g_cond_free(od->condition);
free(od); g_free(od);
} }
static void osx_finishDriver(void *data) static void osx_finishDriver(void *data)

View File

@ -81,7 +81,7 @@ static void free_shout_data(struct shout_data *sd)
if (sd->timer) if (sd->timer)
timer_free(sd->timer); timer_free(sd->timer);
free(sd); g_free(sd);
} }
#define check_block_param(name) { \ #define check_block_param(name) { \

View File

@ -64,12 +64,12 @@ void strset_free(struct strset *set)
while (slot != NULL) { while (slot != NULL) {
next = slot->next; next = slot->next;
free(slot); g_free(slot);
slot = next; slot = next;
} }
} }
free(set); g_free(set);
} }
void strset_add(struct strset *set, const char *value) void strset_add(struct strset *set, const char *value)

View File

@ -115,7 +115,7 @@ void tag_lib_init(void)
s++; s++;
} }
free(temp); g_free(temp);
} }
struct tag *tag_ape_load(const char *file) struct tag *tag_ape_load(const char *file)
@ -234,8 +234,7 @@ struct tag *tag_ape_load(const char *file)
fail: fail:
if (fp) if (fp)
fclose(fp); fclose(fp);
if (buffer) g_free(buffer);
free(buffer);
return ret; return ret;
} }
@ -265,7 +264,7 @@ static void deleteItem(struct tag *tag, int idx)
if (tag->numOfItems > 0) { if (tag->numOfItems > 0) {
tag->items = g_realloc(tag->items, items_size(tag)); tag->items = g_realloc(tag->items, items_size(tag));
} else { } else {
free(tag->items); g_free(tag->items);
tag->items = NULL; tag->items = NULL;
} }
} }
@ -297,11 +296,10 @@ void tag_free(struct tag *tag)
assert(bulk.busy); assert(bulk.busy);
bulk.busy = 0; bulk.busy = 0;
#endif #endif
} else if (tag->items) { } else
free(tag->items); g_free(tag->items);
}
free(tag); g_free(tag);
} }
struct tag *tag_dup(const struct tag *tag) struct tag *tag_dup(const struct tag *tag)

View File

@ -618,7 +618,7 @@ addParentPathToDB(const char *utf8path)
*slash++ = '/'; *slash++ = '/';
} }
free(duplicated); g_free(duplicated);
return directory; return directory;
} }
@ -647,7 +647,7 @@ static void * update_task(void *_path)
{ {
if (_path != NULL && !isRootDirectory(_path)) { if (_path != NULL && !isRootDirectory(_path)) {
updatePath((char *)_path); updatePath((char *)_path);
free(_path); g_free(_path);
} else { } else {
struct directory *directory = db_get_root(); struct directory *directory = db_get_root();
struct stat st; struct stat st;
@ -691,8 +691,7 @@ directory_update_init(char *path)
unsigned next_task_id; unsigned next_task_id;
if (update_paths_nr == G_N_ELEMENTS(update_paths)) { if (update_paths_nr == G_N_ELEMENTS(update_paths)) {
if (path) g_free(path);
free(path);
return 0; return 0;
} }