From: Enlightenment S. <no-...@en...> - 2012-06-28 13:22:24
|
Log: make profile stringshared Author: discomfitor Date: 2012-06-28 06:22:13 -0700 (Thu, 28 Jun 2012) New Revision: 73005 Trac: http://trac.enlightenment.org/e/changeset/73005 Modified: trunk/e/src/bin/e_config.c Modified: trunk/e/src/bin/e_config.c =================================================================== --- trunk/e/src/bin/e_config.c 2012-06-28 13:17:06 UTC (rev 73004) +++ trunk/e/src/bin/e_config.c 2012-06-28 13:22:13 UTC (rev 73005) @@ -24,7 +24,7 @@ /* local subsystem globals */ static int _e_config_save_block = 0; static E_Powersave_Deferred_Action *_e_config_save_defer = NULL; -static char *_e_config_profile = NULL; +static const char *_e_config_profile = NULL; static E_Config_DD *_e_config_edd = NULL; static E_Config_DD *_e_config_module_edd = NULL; @@ -99,14 +99,7 @@ } s = NULL; if (ok) - { - s = malloc(data_len + 1); - if (s) - { - memcpy(s, data, data_len); - s[data_len] = 0; - } - } + eina_stringshare_add_length(data, data_len); free(data); } return s; @@ -120,15 +113,11 @@ E_EVENT_CONFIG_MODE_CHANGED = ecore_event_type_new(); E_EVENT_CONFIG_LOADED = ecore_event_type_new(); - _e_config_profile = getenv("E_CONF_PROFILE"); + /* if environment var set - use this profile name */ + _e_config_profile = eina_stringshare_add(getenv("E_CONF_PROFILE")); - if (_e_config_profile) + if (!_e_config_profile) { - /* if environment var set - use this profile name */ - _e_config_profile = strdup(_e_config_profile); - } - else - { Eet_File *ef; char buf[PATH_MAX]; @@ -181,11 +170,11 @@ /* if so use just the filename as the profile - must be a local link */ if (lnk) { - _e_config_profile = strdup(ecore_file_file_get(lnk)); + _e_config_profile = eina_stringshare_add(ecore_file_file_get(lnk)); free(lnk); } else - _e_config_profile = strdup("default"); + _e_config_profile = eina_stringshare_add("default"); } if (!getenv("E_CONF_PROFILE")) e_util_env_set("E_CONF_PROFILE", _e_config_profile); @@ -933,7 +922,7 @@ EINTERN int e_config_shutdown(void) { - E_FREE(_e_config_profile); + eina_stringshare_del(_e_config_profile); E_CONFIG_DD_FREE(_e_config_edd); E_CONFIG_DD_FREE(_e_config_module_edd); E_CONFIG_DD_FREE(_e_config_font_default_edd); @@ -1413,8 +1402,7 @@ EAPI void e_config_profile_set(const char *prof) { - E_FREE(_e_config_profile); - _e_config_profile = strdup(prof); + eina_stringshare_replace(&_e_config_profile, prof); e_util_env_set("E_CONF_PROFILE", _e_config_profile); } |