mirror of
https://github.com/weechat/weechat.git
synced 2026-07-10 03:33:12 +02:00
core: replace calls to malloc by string_asprintf
This commit is contained in:
+10
-18
@@ -51,7 +51,6 @@ struct t_config_section *plugin_config_section_desc = NULL;
|
||||
struct t_config_option *
|
||||
plugin_config_search (const char *plugin_name, const char *option_name)
|
||||
{
|
||||
int length;
|
||||
char *option_full_name;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
@@ -60,12 +59,10 @@ plugin_config_search (const char *plugin_name, const char *option_name)
|
||||
|
||||
ptr_option = NULL;
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
if (string_asprintf (&option_full_name,
|
||||
"%s.%s",
|
||||
plugin_name, option_name) >= 0)
|
||||
{
|
||||
snprintf (option_full_name, length, "%s.%s",
|
||||
plugin_name, option_name);
|
||||
ptr_option = config_file_search_option (plugin_config_file,
|
||||
plugin_config_section_var,
|
||||
option_full_name);
|
||||
@@ -113,17 +110,15 @@ int
|
||||
plugin_config_set (const char *plugin_name, const char *option_name,
|
||||
const char *value)
|
||||
{
|
||||
int length, rc;
|
||||
int rc;
|
||||
char *option_full_name;
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
if (string_asprintf (&option_full_name,
|
||||
"%s.%s",
|
||||
plugin_name, option_name) >= 0)
|
||||
{
|
||||
snprintf (option_full_name, length, "%s.%s",
|
||||
plugin_name, option_name);
|
||||
rc = plugin_config_set_internal (option_full_name, value);
|
||||
free (option_full_name);
|
||||
}
|
||||
@@ -200,15 +195,12 @@ void
|
||||
plugin_config_set_desc (const char *plugin_name, const char *option_name,
|
||||
const char *description)
|
||||
{
|
||||
int length;
|
||||
char *option_full_name;
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
if (string_asprintf (&option_full_name,
|
||||
"%s.%s",
|
||||
plugin_name, option_name) >= 0)
|
||||
{
|
||||
snprintf (option_full_name, length, "%s.%s",
|
||||
plugin_name, option_name);
|
||||
plugin_config_set_desc_internal (option_full_name, description);
|
||||
free (option_full_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user