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:
parent
7960ad32fc
commit
a45922cd66
@ -183,7 +183,7 @@ void finishAudioDriver(void)
|
||||
audio_output_finish(&audioOutputArray[i]);
|
||||
}
|
||||
|
||||
free(audioOutputArray);
|
||||
g_free(audioOutputArray);
|
||||
audioOutputArray = NULL;
|
||||
audioOutputArraySize = 0;
|
||||
|
||||
|
@ -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, ...)
|
||||
|
@ -125,7 +125,7 @@ db_get_song(const char *file)
|
||||
assert(song->parent == directory);
|
||||
|
||||
out:
|
||||
free(duplicated);
|
||||
g_free(duplicated);
|
||||
return song;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -152,7 +152,7 @@ static void mod_close(mod_Data * data)
|
||||
{
|
||||
Player_Stop();
|
||||
Player_Free(data->moduleHandle);
|
||||
free(data);
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -292,7 +292,7 @@ static void freeOssData(OssData * od)
|
||||
|
||||
mixer_free(od->mixer);
|
||||
|
||||
free(od);
|
||||
g_free(od);
|
||||
}
|
||||
|
||||
#define OSS_STAT_NO_ERROR 0
|
||||
|
@ -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)
|
||||
|
@ -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) { \
|
||||
|
@ -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)
|
||||
|
14
src/tag.c
14
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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user