[vlc-devel] [PATCH] - fixes for trac tickets #2241 and #2242

brezhoneg1 brezhoneg1 at yahoo.fr
Sat Oct 25 11:13:29 CEST 2008


 
Two fixes on /src/text/strings.c
1/ remove the 255 character limitation on str_format_time (trac #2242)
2/ allow lookup of input object to succeed when working with libvlc api
and/or vlm (trac #2241)

--- strings.c.trac	2008-10-25 01:52:36.000000000 +0200
+++ strings.c	2008-10-25 02:09:17.000000000 +0200
@@ -646,17 +646,24 @@
 
************************************************************************
****/
 char *str_format_time( const char *tformat )
 {
-    char buffer[255];
+    char *buffer = NULL;
+    int size;
     time_t curtime;
     struct tm loctime;
 
-    /* Get the current time.  */
+    /* Get the current time. */
     curtime = time( NULL );
 
-    /* Convert it to local time representation.  */
-    localtime_r( &curtime, &loctime );
-    strftime( buffer, 255, tformat, &loctime );
-    return strdup( buffer );
+    size = strlen( tformat ) + 255;
+    buffer = (char*) malloc( size );
+    if ( buffer ) 
+    {
+        /* Convert it to local time representation.  */
+        localtime_r( &curtime, &loctime );
+        strftime( buffer, size, tformat, &loctime );
+    }
+
+    return buffer;
 }
 
 #define INSERT_STRING( string )                                     \
@@ -692,11 +699,13 @@
     char *dst = strdup( string );
     if( !dst ) return NULL;
     int d = 0;
-
-    playlist_t *p_playlist = pl_Hold( p_object );
-    input_thread_t *p_input = playlist_CurrentInput( p_playlist );
+    input_thread_t *p_input = NULL;
     input_item_t *p_item = NULL;
-    pl_Release( p_object );
+
+    p_input = vlc_object_find( p_object, VLC_OBJECT_INPUT, FIND_PARENT
);
+    if ( !p_input )
+        vlc_object_find( p_object, VLC_OBJECT_INPUT, FIND_ANYWHERE );
+
     if( p_input )
     {
         p_item = input_GetItem(p_input);





More information about the vlc-devel mailing list