mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
(load_panelize): replace while() by for() and fix potential memory leak.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
bb142bf47f
commit
13c8f5213b
@ -565,17 +565,14 @@ external_panelize (void)
|
|||||||
void
|
void
|
||||||
load_panelize (void)
|
load_panelize (void)
|
||||||
{
|
{
|
||||||
gchar **profile_keys, **keys;
|
char **keys;
|
||||||
gsize len;
|
gsize len;
|
||||||
GIConv conv;
|
|
||||||
|
|
||||||
conv = str_crt_conv_from ("UTF-8");
|
keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
|
||||||
|
|
||||||
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
|
|
||||||
|
|
||||||
add2panelize (g_strdup (_("Other command")), g_strdup (""));
|
add2panelize (g_strdup (_("Other command")), g_strdup (""));
|
||||||
|
|
||||||
if (!profile_keys || *profile_keys == NULL)
|
if (keys == NULL || *keys == NULL)
|
||||||
{
|
{
|
||||||
add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified"));
|
add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified"));
|
||||||
add2panelize (g_strdup (_("Find rejects after patching")),
|
add2panelize (g_strdup (_("Find rejects after patching")),
|
||||||
@ -585,29 +582,36 @@ load_panelize (void)
|
|||||||
add2panelize (g_strdup (_("Find SUID and SGID programs")),
|
add2panelize (g_strdup (_("Find SUID and SGID programs")),
|
||||||
g_strdup
|
g_strdup
|
||||||
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
|
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
while (*profile_keys)
|
|
||||||
{
|
{
|
||||||
GString *buffer;
|
GIConv conv;
|
||||||
|
char **profile_keys;
|
||||||
|
|
||||||
if (mc_global.utf8_display || conv == INVALID_CONV)
|
conv = str_crt_conv_from ("UTF-8");
|
||||||
buffer = g_string_new (*profile_keys);
|
|
||||||
else
|
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
|
||||||
{
|
{
|
||||||
buffer = g_string_new ("");
|
GString *buffer;
|
||||||
if (str_convert (conv, *profile_keys, buffer) == ESTR_FAILURE)
|
|
||||||
g_string_assign (buffer, *profile_keys);
|
if (mc_global.utf8_display || conv == INVALID_CONV)
|
||||||
|
buffer = g_string_new (*profile_keys);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer = g_string_new ("");
|
||||||
|
if (str_convert (conv, *profile_keys, buffer) == ESTR_FAILURE)
|
||||||
|
g_string_assign (buffer, *profile_keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
add2panelize (g_string_free (buffer, FALSE),
|
||||||
|
mc_config_get_string (mc_main_config, panelize_section, *profile_keys,
|
||||||
|
""));
|
||||||
}
|
}
|
||||||
|
|
||||||
add2panelize (g_string_free (buffer, FALSE),
|
str_close_conv (conv);
|
||||||
mc_config_get_string (mc_main_config, panelize_section, *profile_keys, ""));
|
|
||||||
profile_keys++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_strfreev (keys);
|
g_strfreev (keys);
|
||||||
str_close_conv (conv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user