[Mplayer-cvslog] CVS: main m_config.c,1.6,1.7 m_config.h,1.2,1.3

Alban Bedel CVS albeu at mplayerhq.hu
Sat Apr 12 15:40:59 CEST 2003


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv1986

Modified Files:
	m_config.c m_config.h 
Log Message:
Don't save restore all options wich point to the same variable.


Index: m_config.c
===================================================================
RCS file: /cvsroot/mplayer/main/m_config.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- m_config.c	15 Mar 2003 18:00:28 -0000	1.6
+++ m_config.c	12 Apr 2003 13:40:30 -0000	1.7
@@ -68,7 +68,9 @@
       continue;
     if(co->opt->flags & (M_OPT_GLOBAL|M_OPT_NOSAVE))
       continue;
-    if((co->opt->flags & M_OPT_OLD) && !co->flags)
+    if((co->opt->flags & M_OPT_OLD) && !(co->flags && M_CFG_OPT_SET))
+      continue;
+    if(co->flags & M_CFG_OPT_ALIAS)
       continue;
 
     // Update the current status
@@ -80,8 +82,8 @@
     slot->prev = co->slots;
     co->slots = slot;
     m_option_copy(co->opt,co->slots->data,co->slots->prev->data);
-    // Reset our flags
-    co->flags=0;
+    // Reset our set flag
+    co->flags &= ~M_CFG_OPT_SET;
   }
   
   mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Config pushed level is now %d\n",config->lvl);
@@ -103,6 +105,8 @@
       continue;
     if(co->opt->flags & (M_OPT_GLOBAL|M_OPT_NOSAVE))
       continue;
+    if(co->flags & M_CFG_OPT_ALIAS)
+      continue;
     if(co->slots->lvl > config->lvl)
       mp_msg(MSGT_CFGPARSER, MSGL_WARN,"Too old save slot found from lvl %d : %d !!!\n",config->lvl,co->slots->lvl);
     
@@ -151,6 +155,18 @@
     for(i = 0 ; ol[i].name != NULL ; i++)
       m_config_add_option(config,&ol[i], co->name);
   } else {
+    m_config_option_t *i;
+    // Check if there is alredy an option pointing to this address
+    if(arg->p) {
+      for(i = config->opts ; i ; i = i->next ) {
+	if(i->opt->p == arg->p) { // So we don't save the same vars more than 1 time
+	  co->slots = i->slots;
+	  co->flags |= M_CFG_OPT_ALIAS;
+	  break;
+	}
+      }
+    }
+    if(!(co->flags & M_CFG_OPT_ALIAS)) {
     // Allocate a slot for the defaults
     sl = (m_config_save_slot_t*)calloc(1,sizeof(m_config_save_slot_t) + arg->type->size);
     m_option_save(arg,sl->data,(void**)arg->p);
@@ -165,6 +181,7 @@
     co->slots->prev = sl;
     co->slots->lvl = config->lvl;
     m_option_copy(co->opt,co->slots->data,sl->data);
+    } // !M_OPT_ALIAS
   }
   co->next = config->opts;
   config->opts = co;
@@ -274,7 +291,7 @@
   // Set the option
   if(set) {
     m_option_set(co->opt,co->opt->p,co->slots->data);
-    co->flags = 1;
+    co->flags |= M_CFG_OPT_SET;
   }
 
   return r;

Index: m_config.h
===================================================================
RCS file: /cvsroot/mplayer/main/m_config.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- m_config.h	12 Nov 2002 12:39:05 -0000	1.2
+++ m_config.h	12 Apr 2003 13:40:30 -0000	1.3
@@ -28,6 +28,9 @@
   int mode;
 } m_config_t;
 
+#define M_CFG_OPT_SET    (1<<0)
+#define M_CFG_OPT_ALIAS  (1<<1)
+
 
 //////////////////////////// Functions ///////////////////////////////////
 



More information about the MPlayer-cvslog mailing list