changeset 33751:c28c967e40e9

Replace numeric constant fsPersistant_MaxPos for fsHistory array size. Use macro FF_ARRAY_ELEMS() instead. Additionally, use unsigned index variable for comparison with array size.
author ib
date Thu, 07 Jul 2011 14:47:48 +0000
parents 8b5898908212
children 6cea6d268f97
files gui/cfg.c gui/cfg.h gui/ui/gtk/fileselect.c
diffstat 3 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Thu Jul 07 14:35:31 2011 +0000
+++ b/gui/cfg.c	Thu Jul 07 14:47:48 2011 +0000
@@ -103,7 +103,7 @@
 
 char *skinName;
 
-char *fsHistory[fsPersistant_MaxPos];
+char *fsHistory[5];
 
 static const m_option_t gui_opts[] = {
     { "cache",                       &gtkCacheOn,              CONF_TYPE_FLAG,        0,           0,     1,       NULL },
--- a/gui/cfg.h	Thu Jul 07 14:35:31 2011 +0000
+++ b/gui/cfg.h	Thu Jul 07 14:47:48 2011 +0000
@@ -87,8 +87,7 @@
 
 extern char *skinName;
 
-#define fsPersistant_MaxPos 5
-extern char *fsHistory[fsPersistant_MaxPos];
+extern char *fsHistory[5];
 
 int cfg_gui_include(m_option_t *conf, const char *filename);
 int cfg_read(void);
--- a/gui/ui/gtk/fileselect.c	Thu Jul 07 14:35:31 2011 +0000
+++ b/gui/ui/gtk/fileselect.c	Thu Jul 07 14:47:48 2011 +0000
@@ -37,6 +37,7 @@
 #include "help_mp.h"
 #include "mpcommon.h"
 #include "stream/stream.h"
+#include "libavutil/common.h"
 
 #include "gui/ui/widgets.h"
 #include "fileselect.h"
@@ -332,11 +333,11 @@
 
  if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL;
  {
-  int  i, c = 1;
+  unsigned int  i, c = 1;
 
   if ( fsType == fsVideoSelector )
    {
-    for ( i=0;i < fsPersistant_MaxPos;i++ )
+    for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ )
      if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; }
    }
   if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
@@ -362,18 +363,18 @@
 
 static void fs_PersistantHistory( char * subject )
 {
- int i;
+ unsigned int i;
 
  if ( fsType != fsVideoSelector ) return;
 
- for ( i=0;i < fsPersistant_MaxPos;i++ )
+ for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ )
   if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) )
    {
     char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp;
     return;
    }
- nfree( fsHistory[fsPersistant_MaxPos - 1] );
- for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1];
+ nfree( fsHistory[FF_ARRAY_ELEMS(fsHistory) - 1] );
+ for ( i=FF_ARRAY_ELEMS(fsHistory) - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1];
  fsHistory[0]=gstrdup( subject );
 }
 //-----------------------------------------------