[vlc-devel] [vlc-commits] Qt: playlist_model: don't declare array with non constant expression

Rafaël Carré funman at videolan.org
Fri Mar 2 03:14:42 CET 2012


Hi,

Le 2012-03-01 19:36, Francois Cartegnie a écrit :
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar  2 01:01:29 2012 +0100| [e4a2f9949332e0336dca030b01662503b402c8fe] | committer: Francois Cartegnie
> 
> Qt: playlist_model: don't declare array with non constant expression
> 
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e4a2f9949332e0336dca030b01662503b402c8fe
> ---
> 
>  .../gui/qt4/components/playlist/playlist_model.cpp |   18 ++++++++++++++----
>  1 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
> index f17e7e3..63aa259 100644
> --- a/modules/gui/qt4/components/playlist/playlist_model.cpp
> +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
> @@ -233,7 +233,10 @@ void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
>  {
>      QList<input_item_t*> inputItems = plMimeData->inputItems();
>      QList<PLItem*> model_items;
> -    playlist_item_t *pp_items[inputItems.count()];
> +    playlist_item_t **pp_items;
> +    pp_items = (playlist_item_t **)
> +               calloc( inputItems.count(), sizeof( playlist_item_t* ) );

calloc is not needed (the memory was not zeroed previously)

> +    if ( !pp_items ) return;
>  
>      PL_LOCK;
>  
> @@ -242,7 +245,9 @@ void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
>  
>      if( !p_parent || row > p_parent->i_children )
>      {
> -        PL_UNLOCK; return;
> +        PL_UNLOCK;
> +        free( pp_items );
> +        return;
>      }
>  
>      int new_pos = row == -1 ? p_parent->i_children : row;
> @@ -265,7 +270,9 @@ void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
>          {
>              if( climber == item )
>              {
> -                PL_UNLOCK; return;
> +                PL_UNLOCK;
> +                free( pp_items );
> +                return;
>              }
>              climber = climber->parent();
>          }
> @@ -281,7 +288,9 @@ void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
>  
>      if( model_items.isEmpty() )
>      {
> -        PL_UNLOCK; return;
> +        PL_UNLOCK;
> +        free( pp_items );
> +        return;
>      }
>  
>      playlist_TreeMoveMany( p_playlist, i, pp_items, p_parent, new_pos );
> @@ -292,6 +301,7 @@ void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
>          takeItem( item );
>  
>      insertChildren( target, model_items, model_pos );
> +    free( pp_items );
>  }

could use goto to be shorter



More information about the vlc-devel mailing list