mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
api: return allocated string in hook_info callback and function info_get
This commit is contained in:
@@ -189,8 +189,7 @@ script_completion_scripts_files_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
const char *weechat_home;
|
||||
char *directory;
|
||||
char *weechat_home, *directory;
|
||||
int length, i;
|
||||
void *pointers[2];
|
||||
|
||||
@@ -228,6 +227,9 @@ script_completion_scripts_files_cb (const void *pointer, void *data,
|
||||
free (directory);
|
||||
}
|
||||
|
||||
if (weechat_home)
|
||||
free (weechat_home);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ struct t_config_option *script_config_scripts_url;
|
||||
const char *
|
||||
script_config_get_diff_command ()
|
||||
{
|
||||
const char *diff_command, *dir_separator;
|
||||
const char *diff_command;
|
||||
char *dir_separator;
|
||||
static char result[64];
|
||||
struct stat st;
|
||||
char *path, **paths, bin[4096];
|
||||
@@ -135,6 +136,8 @@ script_config_get_diff_command ()
|
||||
weechat_string_free_split (paths);
|
||||
}
|
||||
}
|
||||
if (dir_separator)
|
||||
free (dir_separator);
|
||||
if (!result[0])
|
||||
snprintf (result, sizeof (result), "diff");
|
||||
return result;
|
||||
|
||||
@@ -166,8 +166,7 @@ script_repo_search_by_name_ext (const char *name_with_extension)
|
||||
char *
|
||||
script_repo_get_filename_loaded (struct t_script_repo *script)
|
||||
{
|
||||
const char *weechat_home;
|
||||
char *filename, resolved_path[PATH_MAX];
|
||||
char *weechat_home, *filename, resolved_path[PATH_MAX];
|
||||
int length;
|
||||
struct stat st;
|
||||
|
||||
@@ -175,7 +174,11 @@ script_repo_get_filename_loaded (struct t_script_repo *script)
|
||||
length = strlen (weechat_home) + strlen (script->name_with_extension) + 64;
|
||||
filename = malloc (length);
|
||||
if (!filename)
|
||||
{
|
||||
if (weechat_home)
|
||||
free (weechat_home);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf (filename, length, "%s/%s/autoload/%s",
|
||||
weechat_home,
|
||||
@@ -193,6 +196,9 @@ script_repo_get_filename_loaded (struct t_script_repo *script)
|
||||
}
|
||||
}
|
||||
|
||||
if (weechat_home)
|
||||
free (weechat_home);
|
||||
|
||||
if (!filename[0])
|
||||
{
|
||||
free (filename);
|
||||
@@ -801,8 +807,8 @@ script_repo_sha512sum_file (const char *filename)
|
||||
void
|
||||
script_repo_update_status (struct t_script_repo *script)
|
||||
{
|
||||
const char *weechat_home, *version;
|
||||
char *filename, *sha512sum;
|
||||
const char *version;
|
||||
char *weechat_home, *filename, *sha512sum;
|
||||
struct stat st;
|
||||
int length;
|
||||
struct t_script_repo *ptr_script;
|
||||
@@ -841,6 +847,9 @@ script_repo_update_status (struct t_script_repo *script)
|
||||
free (filename);
|
||||
}
|
||||
|
||||
if (weechat_home)
|
||||
free (weechat_home);
|
||||
|
||||
/* check if script is held */
|
||||
if (script_repo_script_is_held (script))
|
||||
script->status |= SCRIPT_STATUS_HELD;
|
||||
@@ -1140,8 +1149,8 @@ script_repo_file_read (int quiet)
|
||||
{
|
||||
char *filename, *ptr_line, line[4096], *pos, *pos2, *pos3;
|
||||
char *name, *value1, *value2, *value3, *value, *error;
|
||||
char *locale, *locale_language;
|
||||
const char *version, *ptr_locale, *ptr_desc;
|
||||
char *info_locale, *locale, *locale_language, *version;
|
||||
const char *ptr_desc;
|
||||
gzFile file;
|
||||
struct t_script_repo *script;
|
||||
int version_number, version_ok, script_ok, length;
|
||||
@@ -1166,6 +1175,8 @@ script_repo_file_read (int quiet)
|
||||
|
||||
version = weechat_info_get ("version", NULL);
|
||||
version_number = weechat_util_version_number (version);
|
||||
if (version)
|
||||
free (version);
|
||||
|
||||
filename = script_config_get_xml_filename ();
|
||||
if (!filename)
|
||||
@@ -1195,14 +1206,15 @@ script_repo_file_read (int quiet)
|
||||
*/
|
||||
locale = NULL;
|
||||
locale_language = NULL;
|
||||
ptr_locale = weechat_info_get ("locale", NULL);
|
||||
if (ptr_locale)
|
||||
info_locale = weechat_info_get ("locale", NULL);
|
||||
if (info_locale)
|
||||
{
|
||||
pos = strchr (ptr_locale, '.');
|
||||
pos = strchr (info_locale, '.');
|
||||
if (pos)
|
||||
locale = weechat_strndup (ptr_locale, pos - ptr_locale);
|
||||
locale = weechat_strndup (info_locale, pos - info_locale);
|
||||
else
|
||||
locale = strdup (ptr_locale);
|
||||
locale = strdup (info_locale);
|
||||
free (info_locale);
|
||||
}
|
||||
if (locale)
|
||||
{
|
||||
@@ -1406,10 +1418,13 @@ script_repo_file_read (int quiet)
|
||||
|
||||
if (scripts_repo && !quiet)
|
||||
{
|
||||
version = weechat_info_get ("version", NULL);
|
||||
weechat_printf (NULL,
|
||||
_("%s: %d scripts for WeeChat %s"),
|
||||
SCRIPT_PLUGIN_NAME, script_repo_count,
|
||||
weechat_info_get ("version", NULL));
|
||||
version);
|
||||
if (version)
|
||||
free (version);
|
||||
}
|
||||
|
||||
if (!scripts_repo)
|
||||
|
||||
Reference in New Issue
Block a user