[prev in list] [next in list] [prev in thread] [next in thread]
List: xine-cvslog
Subject: [xine-cvs] CVS: gnome-xine/src play_item.c,1.18,1.19
From: Darren Salt <dsalt () users ! sourceforge ! net>
Date: 2005-01-27 18:14:02
Message-ID: E1CuE9a-0003My-5m () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/xine/gnome-xine/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12685/src
Modified Files:
play_item.c
Log Message:
Tidy up default title creation.
Remove an unused function and stop a memory leak when saving the play list.
Index: play_item.c
===================================================================
RCS file: /cvsroot/xine/gnome-xine/src/play_item.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- play_item.c 27 Jan 2005 02:45:34 -0000 1.18
+++ play_item.c 27 Jan 2005 18:13:47 -0000 1.19
@@ -47,27 +47,34 @@
if (!title)
{
/* find the leafname of the MRL */
- title = strrchr (mrl, '/');
+ char *end, *retitle = strdup (mrl);
+ if ((end = strchr (retitle, '#')))
+ *end = 0; /* lose parameters suffix (if present) */
+
+ title = strrchr (retitle, '/');
if (title && !title[1]) /* ends in '/' - look for preceding '/' */
{
while (*title == '/')
- if (--title == mrl)
+ if (--title == retitle)
break;
while (*title != '/')
- if (--title < mrl)
+ if (--title < retitle)
break;
}
- /* at this point, title >= mrl - 1, but mrl[-1] is invalid - this is OK
- * in the case where title == mrl - 1, we use the full MRL as the title
+ /* at this point, title >= retitle - 1
+ * retitle[-1] being invalid doesn't matter
*/
- if (title >= mrl && title[1])
+ if (title[1])
{
- /* URL-decode the leafname */
- char *dot, *retitle = play_item->title = malloc (strlen (title));
int i = 0, j = -1;
+ /* Strip the extension and suffix (if present) */
+ if ((end = strrchr (title + 1, '.')))
+ *end = 0;
+
+ /* URL-decode the leafname */
while (title[++i])
{
if (title[i] == '%')
@@ -81,26 +88,22 @@
}
/* NUL-terminate, strip trailing / */
retitle[j + (retitle[j] != '/')] = 0;
-
- /* Strip the extension and suffix (if present) */
- dot = strrchr (retitle, '.');
- if (dot)
- *dot = 0;
- dot = strrchr (retitle, '#');
- if (dot)
- *dot = 0;
+ play_item->title = realloc (retitle, strlen (retitle) + 1);
}
else
- play_item->title = strdup (mrl);
+ {
+ free (retitle);
+ play_item->title = strdup (mrl);
+ }
}
else
play_item->title = strdup (title);
play_item->mrl = strdup (mrl);
- play_item->start_time = start_time,
+ play_item->start_time = start_time;
play_item->options = NULL;
play_item->played = 0;
-
+
return play_item;
}
@@ -147,12 +150,6 @@
}
-static void printf_depth (FILE *fh, int depth) {
- int i;
- for (i=0; i<depth; i++)
- fprintf (fh, " ");
-}
-
void play_item_save (play_item_t *item, FILE *fh, int depth)
{
char *title = xml_escape_string (item->title, XML_ESCAPE_NO_QUOTE);
@@ -174,6 +171,7 @@
indent);
free (title);
free (mrl);
+ free (indent);
}
play_item_t *play_item_load (xml_node_t *node) {
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Xine-cvslog mailing list
Xine-cvslog@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xine-cvslog
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic