[xiph-commits] r12685 - trunk/ezstream/src
moritz at svn.xiph.org
moritz at svn.xiph.org
Thu Mar 8 12:59:32 PST 2007
Author: moritz
Date: 2007-03-08 12:59:29 -0800 (Thu, 08 Mar 2007)
New Revision: 12685
Modified:
trunk/ezstream/src/ezstream.c
trunk/ezstream/src/playlist.c
trunk/ezstream/src/playlist.h
Log:
Fix playlist_free() as well ...
Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c 2007-03-08 20:24:09 UTC (rev 12684)
+++ trunk/ezstream/src/ezstream.c 2007-03-08 20:59:29 UTC (rev 12685)
@@ -1033,7 +1033,7 @@
shout_close(shout);
- playlist_free(playlist);
+ playlist_free(&playlist);
playlist_shutdown();
shout_shutdown();
Modified: trunk/ezstream/src/playlist.c
===================================================================
--- trunk/ezstream/src/playlist.c 2007-03-08 20:24:09 UTC (rev 12684)
+++ trunk/ezstream/src/playlist.c 2007-03-08 20:59:29 UTC (rev 12685)
@@ -141,7 +141,7 @@
if ((filep = fopen(filename, "r")) == NULL) {
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
@@ -183,7 +183,7 @@
/* We got one. */
if (!playlist_add(pl, buf)) {
fclose(filep);
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
}
@@ -191,7 +191,7 @@
printf("%s: playlist_read(): Error while reading %s: %s\n",
__progname, filename, strerror(errno));
fclose(filep);
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
@@ -215,18 +215,18 @@
#ifdef HAVE_STAT
if (stat(filename, &st) == -1) {
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
printf("%s: %s: Not an executable program\n", __progname, filename);
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
#else
if ((filep = fopen(filename, "r")) == NULL) {
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
- playlist_free(pl);
+ playlist_free(&pl);
return (NULL);
}
fclose(filep);
@@ -236,32 +236,36 @@
}
void
-playlist_free(playlist_t *pl)
+playlist_free(playlist_t **pl)
{
- size_t i;
+ size_t i;
+ playlist_t *tmp;
- if (pl != NULL) {
- if (pl->filename != NULL)
- xfree(pl->filename);
+ if (pl == NULL || *pl == NULL)
+ return;
- if (pl->list != NULL) {
- if (pl->size > 0) {
- for (i = 0; i < pl->size / sizeof(char *); i++) {
- if (pl->list[i] != NULL)
- xfree(pl->list[i]);
- else
- break;
- }
+ tmp = *pl;
+
+ if (tmp->filename != NULL)
+ xfree(tmp->filename);
+
+ if (tmp->list != NULL) {
+ if (tmp->size > 0) {
+ for (i = 0; i < tmp->size / sizeof(char *); i++) {
+ if (tmp->list[i] != NULL)
+ xfree(tmp->list[i]);
+ else
+ break;
}
-
- xfree(pl->list);
}
- if (pl->prog_track != NULL)
- xfree(pl->prog_track);
+ xfree(tmp->list);
+ }
- xfree(pl);
- }
+ if (tmp->prog_track != NULL)
+ xfree(tmp->prog_track);
+
+ xfree(pl);
}
const char *
@@ -415,7 +419,7 @@
if ((new_pl = playlist_read(pl->filename)) == NULL)
return (0);
- playlist_free(pl);
+ playlist_free(&pl);
*plist = new_pl;
return (1);
Modified: trunk/ezstream/src/playlist.h
===================================================================
--- trunk/ezstream/src/playlist.h 2007-03-08 20:24:09 UTC (rev 12684)
+++ trunk/ezstream/src/playlist.h 2007-03-08 20:59:29 UTC (rev 12685)
@@ -47,7 +47,7 @@
* Free all memory used by a playlist handler that was created with
* playlist_read().
*/
-void playlist_free(playlist_t *);
+void playlist_free(playlist_t **);
/*
* Get the next item in the playlist. Returns a NUL-terminated string of a
More information about the commits
mailing list