1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Now that xalloc is pretty much an external entity, explicitly set freed

pointers to NULL if we lateron expect them to be NULL (no longer rely on
xalloc to do this for us.)


git-svn-id: https://svn.xiph.org/trunk/ezstream@13436 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
moritz 2007-08-04 16:39:09 +00:00
parent f282e3d474
commit 53fa75fdba
3 changed files with 42 additions and 21 deletions

View File

@ -839,6 +839,7 @@ streamFile(shout_t *shout, const char *fileName)
else
printf("\n");
xfree(metaData);
metaData = NULL;
}
#ifdef HAVE_GETTIMEOFDAY

View File

@ -109,8 +109,10 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
taglib_set_string_management_enabled(0);
taglib_set_strings_unicode(0);
if (md->string != NULL)
if (md->string != NULL) {
xfree(md->string);
md->string = NULL;
}
if ((tf = taglib_file_new(md->filename)) == NULL) {
md->string = metadata_get_name(md->filename);
@ -248,12 +250,18 @@ metadata_clean_md(metadata_t *md)
abort();
}
if (md->string != NULL)
if (md->string != NULL) {
xfree(md->string);
if (md->artist != NULL)
md->string = NULL;
}
if (md->artist != NULL) {
xfree(md->artist);
if (md->title != NULL)
md->artist = NULL;
}
if (md->title != NULL) {
xfree(md->title);
md->title = NULL;
}
}
void
@ -388,19 +396,20 @@ metadata_program(const char *program)
}
void
metadata_free(metadata_t **md)
metadata_free(metadata_t **md_p)
{
metadata_t *tmp;
metadata_t *md;
if (md == NULL || *md == NULL)
if (md_p == NULL || (md = *md_p) == NULL)
return;
tmp = *md;
if (tmp->filename != NULL)
xfree(tmp->filename);
metadata_clean_md(tmp);
xfree(*md);
if (md->filename != NULL) {
xfree(md->filename);
md->filename = NULL;
}
metadata_clean_md(md);
xfree(*md_p);
*md_p = NULL;
}
@ -467,18 +476,24 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
return (1);
case METADATA_STRING:
strlcpy(command, md->filename, sizeof(command));
if (md->string != NULL)
if (md->string != NULL) {
xfree(md->string);
md->string = NULL;
}
break;
case METADATA_ARTIST:
snprintf(command, sizeof(command), "%s artist", md->filename);
if (md->artist != NULL)
if (md->artist != NULL) {
xfree(md->artist);
md->artist = NULL;
}
break;
case METADATA_TITLE:
snprintf(command, sizeof(command), "%s title", md->filename);
if (md->title != NULL)
if (md->title != NULL) {
xfree(md->title);
md->title = NULL;
}
break;
default:
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",

View File

@ -244,7 +244,7 @@ playlist_program(const char *filename)
void
playlist_free(playlist_t **pl)
{
size_t i;
size_t i;
playlist_t *tmp;
if (pl == NULL || *pl == NULL)
@ -252,15 +252,18 @@ playlist_free(playlist_t **pl)
tmp = *pl;
if (tmp->filename != NULL)
if (tmp->filename != NULL) {
xfree(tmp->filename);
tmp->filename = NULL;
}
if (tmp->list != NULL) {
if (tmp->size > 0) {
for (i = 0; i < tmp->size / sizeof(char *); i++) {
if (tmp->list[i] != NULL)
if (tmp->list[i] != NULL) {
xfree(tmp->list[i]);
else
tmp->list[i] = NULL;
} else
break;
}
}
@ -268,8 +271,10 @@ playlist_free(playlist_t **pl)
xfree(tmp->list);
}
if (tmp->prog_track != NULL)
if (tmp->prog_track != NULL) {
xfree(tmp->prog_track);
tmp->prog_track = NULL;
}
xfree(*pl);
}