[xiph-commits] r13436 - trunk/ezstream/src

moritz at svn.xiph.org moritz at svn.xiph.org
Sat Aug 4 09:39:09 PDT 2007


Author: moritz
Date: 2007-08-04 09:39:09 -0700 (Sat, 04 Aug 2007)
New Revision: 13436

Modified:
   trunk/ezstream/src/ezstream.c
   trunk/ezstream/src/metadata.c
   trunk/ezstream/src/playlist.c
Log:
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.)


Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2007-08-04 16:35:23 UTC (rev 13435)
+++ trunk/ezstream/src/ezstream.c	2007-08-04 16:39:09 UTC (rev 13436)
@@ -839,6 +839,7 @@
 		else
 			printf("\n");
 		xfree(metaData);
+		metaData = NULL;
 	}
 
 #ifdef HAVE_GETTIMEOFDAY

Modified: trunk/ezstream/src/metadata.c
===================================================================
--- trunk/ezstream/src/metadata.c	2007-08-04 16:35:23 UTC (rev 13435)
+++ trunk/ezstream/src/metadata.c	2007-08-04 16:39:09 UTC (rev 13436)
@@ -109,8 +109,10 @@
 	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 @@
 		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 @@
 }
 
 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 @@
 			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",

Modified: trunk/ezstream/src/playlist.c
===================================================================
--- trunk/ezstream/src/playlist.c	2007-08-04 16:35:23 UTC (rev 13435)
+++ trunk/ezstream/src/playlist.c	2007-08-04 16:39:09 UTC (rev 13436)
@@ -244,7 +244,7 @@
 void
 playlist_free(playlist_t **pl)
 {
-	size_t		i;
+	size_t		 i;
 	playlist_t	*tmp;
 
 	if (pl == NULL || *pl == NULL)
@@ -252,15 +252,18 @@
 
 	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 @@
 		xfree(tmp->list);
 	}
 
-	if (tmp->prog_track != NULL)
+	if (tmp->prog_track != NULL) {
 		xfree(tmp->prog_track);
+		tmp->prog_track = NULL;
+	}
 
 	xfree(*pl);
 }



More information about the commits mailing list