From d18c4f1d1e8b44e4cbba62dac97b62127fa700a7 Mon Sep 17 00:00:00 2001 From: albeu Date: Sat, 12 Apr 2003 13:40:30 +0000 Subject: Don't save restore all options wich point to the same variable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9913 b3059339-0415-0410-9bf9-f77b7e298cf2 --- m_config.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'm_config.c') diff --git a/m_config.c b/m_config.c index 06f32fc400..9da952ac46 100644 --- a/m_config.c +++ b/m_config.c @@ -68,7 +68,9 @@ m_config_push(m_config_t* config) { 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 @@ m_config_push(m_config_t* config) { 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 @@ m_config_pop(m_config_t* config) { 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 @@ m_config_add_option(m_config_t *config, m_option_t *arg, char* prefix) { 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 @@ m_config_add_option(m_config_t *config, m_option_t *arg, char* prefix) { 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 @@ m_config_parse_option(m_config_t *config, char* arg, char* param,int set) { // 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; -- cgit v1.2.3