changeset 9912:39444d65c4cb

Don't save restore all options wich point to the same variable.
author albeu
date Sat, 12 Apr 2003 13:40:30 +0000
parents fa45d335a43b
children 88fe89b46786
files m_config.c m_config.h
diffstat 2 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/m_config.c	Sat Apr 12 09:30:19 2003 +0000
+++ b/m_config.c	Sat Apr 12 13:40:30 2003 +0000
@@ -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;
--- a/m_config.h	Sat Apr 12 09:30:19 2003 +0000
+++ b/m_config.h	Sat Apr 12 13:40:30 2003 +0000
@@ -28,6 +28,9 @@
   int mode;
 } m_config_t;
 
+#define M_CFG_OPT_SET    (1<<0)
+#define M_CFG_OPT_ALIAS  (1<<1)
+
 
 //////////////////////////// Functions ///////////////////////////////////