ryuan pushed a commit to branch master.
commit ef5b8dc73e52e0c2485a8c3dbb6a38c411e83182
Author: Ryuan Choi <[email protected]>
Date: Wed Sep 11 08:39:59 2013 +0900
config: Remove unnecessary alloc/free in _profile_fetch_from_conf()
---
src/lib/elm_config.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index 2fcb6f0..d5a3b91 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -867,13 +867,10 @@ _profile_fetch_from_conf(void)
Eet_File *ef = NULL;
int len = 0;
- _elm_profile = strdup("default");
-
// if env var - use profile without question
s = getenv("ELM_PROFILE");
if (s)
{
- free(_elm_profile);
_elm_profile = strdup(s);
return;
}
@@ -886,16 +883,15 @@ _profile_fetch_from_conf(void)
p = eet_read(ef, "config", &len);
if (p)
{
- free(_elm_profile);
_elm_profile = malloc(len + 1);
memcpy(_elm_profile, p, len);
_elm_profile[len] = 0;
free(p);
+ eet_close(ef);
+ return;
}
eet_close(ef);
- if (!p) ef = NULL;
}
- if (ef) return;
// system profile
_elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
@@ -905,14 +901,17 @@ _profile_fetch_from_conf(void)
p = eet_read(ef, "config", &len);
if (p)
{
- free(_elm_profile);
_elm_profile = malloc(len + 1);
memcpy(_elm_profile, p, len);
_elm_profile[len] = 0;
free(p);
+ eet_close(ef);
+ return;
}
eet_close(ef);
}
+
+ _elm_profile = strdup("default");
}
static void
--
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk