Changeset 140517913b5dce1fa54cb23ff6c37b526d904b76

Show
Ignore:
Timestamp:
19/11/07 13:58:21 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1195477101 +0000
git-parent:

[55287bbffd7ddce57a05316560b225f9701550a4]

git-author:
Rafaël Carré <funman@videolan.org> 1195477101 +0000
Message:

ncurses: display the input's title if it's present instead of the name. Use asprintf()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/ncurses.c

    r55287bb r1405179  
    19051905    intf_sys_t *p_sys = p_intf->p_sys; 
    19061906    playlist_item_t *p_child; 
    1907     char *psz_tmp; 
    19081907    int k; 
    19091908 
    1910     psz_tmp = (char *)malloc( strlen( c ) + 4 ); 
    1911     if( psz_tmp == NULL ) return; 
    19121909    for( k = 0; k < p_node->i_children; k++ ) 
    19131910    { 
    1914         struct pl_item_t *p_pl_item; 
    1915         char *buff; 
    1916         int i_size; 
    1917  
     1911        char *psz_display; 
    19181912        p_child = p_node->pp_children[k]; 
    1919         i_size = strlen( c ) + strlen( p_child->p_input->psz_name ) + 4; 
    1920         buff = (char *)malloc( sizeof( char ) * i_size ); 
    1921         p_pl_item = (struct pl_item_t *)malloc( sizeof( struct pl_item_t ) ); 
    1922         if( p_pl_item == NULL || buff == NULL ) return; 
    1923  
    1924         if( strlen( c ) ) 
    1925         { 
    1926             sprintf( buff, "%s%c-%s", c, k == p_node->i_children - 1 ? 
    1927                      '`' : '|', p_child->p_input->psz_name ); 
     1913        char *psz_name = input_item_GetTitle( p_child->p_input ); 
     1914        if( !psz_name || !*psz_name ) 
     1915        { 
     1916            free( psz_name ); 
     1917            psz_name = input_item_GetName( p_child->p_input ); 
     1918        } 
     1919 
     1920        if( c && *c ) 
     1921        { 
     1922            if( asprintf( &psz_display, "%s%c-%s", c, 
     1923                    k == p_node->i_children - 1 ?  '`' : '|', psz_name ) == -1 ) 
     1924                return; 
    19281925        } 
    19291926        else 
    19301927        { 
    1931             sprintf( buff, " %s", p_child->p_input->psz_name ); 
    1932         } 
    1933         p_pl_item->psz_display = strdup( buff ); 
     1928            if( asprintf( &psz_display, " %s", psz_name ) == -1 ) 
     1929                return; 
     1930        } 
     1931        free( psz_name ); 
     1932        struct pl_item_t *p_pl_item = malloc( sizeof( struct pl_item_t ) ); 
     1933        if( !p_pl_item ) 
     1934            return; 
     1935        p_pl_item->psz_display = psz_display; 
    19341936        p_pl_item->p_item = p_child; 
    19351937        INSERT_ELEM( p_sys->pp_plist, p_sys->i_plist_entries, 
    19361938                     p_sys->i_plist_entries, p_pl_item ); 
    1937         free( buff ); 
    19381939        i++; 
    19391940 
    19401941        if( p_child->i_children > 0 ) 
    19411942        { 
    1942             sprintf( psz_tmp, "%s%c ", c, 
    1943                      k == p_node->i_children - 1 ? ' ' : '|' ); 
     1943            char *psz_tmp; 
     1944            if( asprintf( &psz_tmp, "%s%c ", c, 
     1945                     k == p_node->i_children - 1 ? ' ' : '|' ) == -1 ) 
     1946                return;  
    19441947            PlaylistAddNode( p_intf, p_child, i, 
    19451948                             strlen( c ) ? psz_tmp : " " ); 
    1946         } 
    1947    
    1948     free( psz_tmp ); 
     1949            free( psz_tmp ); 
     1950       
     1951    } 
    19491952} 
    19501953