[vlc-devel] [PATCH] playlist/directory: ignore case when sorting files

Thomas Guillem thomas at gllm.fr
Thu Aug 20 16:13:26 CEST 2015



On Thu, Aug 20, 2015, at 15:30, Francois Cartegnie wrote:
> Le 20/08/2015 14:48, Thomas Guillem a écrit :
> > +#ifdef HAVE_STRCOLL
> > +    /* The program's LOCAL defines if case is ignored */
> > +
> > +    /* strxfrm(NULL, src, 0) returns the number of bytes required for the
> > +     * transformation */
> > +    char *psz_name1 = malloc( strxfrm( NULL, p1->psz_name, 0 ) + 1 );
> > +    char *psz_name2 = malloc( strxfrm( NULL, p2->psz_name, 0 ) + 1 );
> > +    if( !psz_name1 || !psz_name2 )
> > +        return 0;
> > +
> > +    strxfrm( psz_name1, p1->psz_name, sizeof(psz_name1) );
> > +    strxfrm( psz_name2, p2->psz_name, sizeof(psz_name2) );
> 
> man strxfrm:
>  If the value returned is n or more, the contents of dest are
>        indeterminate.
> 
>  The strxfrm() function may fail [...]

The first call to strxfrm with NULL and 0 arguments returns the size
needed for the transformation. Therefore, the second call to strxfrm
with the same string can't fail since the dst buffer is allocated with
the good size.

> 
> 
> Francois
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list