1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -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 else
printf("\n"); printf("\n");
xfree(metaData); xfree(metaData);
metaData = NULL;
} }
#ifdef HAVE_GETTIMEOFDAY #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_string_management_enabled(0);
taglib_set_strings_unicode(0); taglib_set_strings_unicode(0);
if (md->string != NULL) if (md->string != NULL) {
xfree(md->string); xfree(md->string);
md->string = NULL;
}
if ((tf = taglib_file_new(md->filename)) == NULL) { if ((tf = taglib_file_new(md->filename)) == NULL) {
md->string = metadata_get_name(md->filename); md->string = metadata_get_name(md->filename);
@ -248,12 +250,18 @@ metadata_clean_md(metadata_t *md)
abort(); abort();
} }
if (md->string != NULL) if (md->string != NULL) {
xfree(md->string); xfree(md->string);
if (md->artist != NULL) md->string = NULL;
}
if (md->artist != NULL) {
xfree(md->artist); xfree(md->artist);
if (md->title != NULL) md->artist = NULL;
}
if (md->title != NULL) {
xfree(md->title); xfree(md->title);
md->title = NULL;
}
} }
void void
@ -388,19 +396,20 @@ metadata_program(const char *program)
} }
void 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; return;
tmp = *md; if (md->filename != NULL) {
xfree(md->filename);
if (tmp->filename != NULL) md->filename = NULL;
xfree(tmp->filename); }
metadata_clean_md(tmp); metadata_clean_md(md);
xfree(*md); xfree(*md_p);
*md_p = NULL;
} }
@ -467,18 +476,24 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
return (1); return (1);
case METADATA_STRING: case METADATA_STRING:
strlcpy(command, md->filename, sizeof(command)); strlcpy(command, md->filename, sizeof(command));
if (md->string != NULL) if (md->string != NULL) {
xfree(md->string); xfree(md->string);
md->string = NULL;
}
break; break;
case METADATA_ARTIST: case METADATA_ARTIST:
snprintf(command, sizeof(command), "%s artist", md->filename); snprintf(command, sizeof(command), "%s artist", md->filename);
if (md->artist != NULL) if (md->artist != NULL) {
xfree(md->artist); xfree(md->artist);
md->artist = NULL;
}
break; break;
case METADATA_TITLE: case METADATA_TITLE:
snprintf(command, sizeof(command), "%s title", md->filename); snprintf(command, sizeof(command), "%s title", md->filename);
if (md->title != NULL) if (md->title != NULL) {
xfree(md->title); xfree(md->title);
md->title = NULL;
}
break; break;
default: default:
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n", printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",

View File

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