Removed sizeof(char) and useless type casts from void* to another pointer type (patch from Leonid Evdokimov)
parent
14feea7ab8
commit
57323fa71e
|
@ -1738,7 +1738,7 @@ char *adder (t_weechat_plugin *plugin, int argc, char **argv,
|
|||
char *modifier_args, void *modifier_pointer)
|
||||
{
|
||||
char *string;
|
||||
string = (char *)malloc (strlen (argv[1]) + 16);
|
||||
string = malloc (strlen (argv[1]) + 16);
|
||||
strcpy (string, argv[1]);
|
||||
strcat (string, "test");
|
||||
return string;
|
||||
|
|
|
@ -3072,7 +3072,7 @@ char *adder (t_weechat_plugin *plugin, int argc, char **argv,
|
|||
char *modifier_args, void *modifier_pointer)
|
||||
{
|
||||
char *string;
|
||||
string = (char *)malloc (strlen (argv[1]) + 16);
|
||||
string = malloc (strlen (argv[1]) + 16);
|
||||
strcpy (string, argv[1]);
|
||||
strcat (string, "test");
|
||||
return string;
|
||||
|
|
|
@ -1695,7 +1695,7 @@ char *adder (t_weechat_plugin *plugin, int argc, char **argv,
|
|||
char *modifier_args, void *modifier_pointer)
|
||||
{
|
||||
char *string;
|
||||
string = (char *)malloc (strlen (argv[1]) + 16);
|
||||
string = malloc (strlen (argv[1]) + 16);
|
||||
strcpy (string, argv[1]);
|
||||
strcat (string, "test");
|
||||
return string;
|
||||
|
|
|
@ -1758,7 +1758,7 @@ char *adder (t_weechat_plugin *plugin, int argc, char **argv,
|
|||
char *modifier_args, void *modifier_pointer)
|
||||
{
|
||||
char *string;
|
||||
string = (char *)malloc (strlen (argv[1]) + 16);
|
||||
string = malloc (strlen (argv[1]) + 16);
|
||||
strcpy (string, argv[1]);
|
||||
strcat (string, "test");
|
||||
return string;
|
||||
|
|
|
@ -526,7 +526,7 @@ command_builtin (void *data, struct t_gui_buffer *buffer,
|
|||
else
|
||||
{
|
||||
length = strlen (argv_eol[1]) + 2;
|
||||
command = (char *)malloc (length * sizeof (char));
|
||||
command = malloc (length);
|
||||
if (command)
|
||||
{
|
||||
snprintf (command, length, "/%s", argv_eol[1]);
|
||||
|
@ -1950,7 +1950,7 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
|
|||
}
|
||||
|
||||
filename_length = strlen (weechat_home) + strlen (WEECHAT_SESSION_NAME) + 2;
|
||||
filename = (char *)malloc (filename_length * sizeof (char));
|
||||
filename = malloc (filename_length);
|
||||
if (!filename)
|
||||
return -2;
|
||||
snprintf (filename, filename_length, "%s%s" WEECHAT_SESSION_NAME,
|
||||
|
|
|
@ -86,7 +86,7 @@ config_file_new (struct t_weechat_plugin *plugin, char *filename,
|
|||
if (config_file_search (filename))
|
||||
return NULL;
|
||||
|
||||
new_config_file = (struct t_config_file *)malloc (sizeof (struct t_config_file));
|
||||
new_config_file = malloc (sizeof (*new_config_file));
|
||||
if (new_config_file)
|
||||
{
|
||||
new_config_file->plugin = plugin;
|
||||
|
@ -157,7 +157,7 @@ config_file_new_section (struct t_config_file *config_file, char *name,
|
|||
if (!config_file || !name)
|
||||
return NULL;
|
||||
|
||||
new_section = (struct t_config_section *)malloc (sizeof (struct t_config_section));
|
||||
new_section = malloc (sizeof (*new_section));
|
||||
if (new_section)
|
||||
{
|
||||
new_section->name = strdup (name);
|
||||
|
@ -275,7 +275,7 @@ config_file_new_option (struct t_config_file *config_file,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option));
|
||||
new_option = malloc (sizeof (*new_option));
|
||||
if (new_option)
|
||||
{
|
||||
new_option->name = strdup (name);
|
||||
|
@ -849,8 +849,7 @@ config_file_write_internal (struct t_config_file *config_file,
|
|||
/* build filename */
|
||||
filename_length = strlen (weechat_home) +
|
||||
strlen (config_file->filename) + 2;
|
||||
filename =
|
||||
(char *)malloc (filename_length * sizeof (char));
|
||||
filename = malloc (filename_length);
|
||||
if (!filename)
|
||||
return -2;
|
||||
snprintf (filename, filename_length, "%s%s%s",
|
||||
|
@ -858,7 +857,7 @@ config_file_write_internal (struct t_config_file *config_file,
|
|||
|
||||
/* build temporary filename, this temp file will be renamed to filename
|
||||
after write */
|
||||
filename2 = (char *)malloc ((filename_length + 32) * sizeof (char));
|
||||
filename2 = malloc (filename_length + 32);
|
||||
if (!filename2)
|
||||
{
|
||||
free (filename);
|
||||
|
@ -972,7 +971,7 @@ config_file_read (struct t_config_file *config_file)
|
|||
|
||||
/* build filename */
|
||||
filename_length = strlen (weechat_home) + strlen (config_file->filename) + 2;
|
||||
filename = (char *)malloc (filename_length * sizeof (char));
|
||||
filename = malloc (filename_length);
|
||||
if (!filename)
|
||||
return -2;
|
||||
snprintf (filename, filename_length, "%s%s%s",
|
||||
|
|
|
@ -330,10 +330,10 @@ hook_command (struct t_weechat_plugin *plugin, char *command, char *description,
|
|||
}
|
||||
}
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_command = (struct t_hook_command *)malloc (sizeof (struct t_hook_command));
|
||||
new_hook_command = malloc (sizeof (*new_hook_command));
|
||||
if (!new_hook_command)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -441,10 +441,10 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
|
|||
struct t_hook_timer *new_hook_timer;
|
||||
struct timezone tz;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_timer = (struct t_hook_timer *)malloc (sizeof (struct t_hook_timer));
|
||||
new_hook_timer = malloc (sizeof (*new_hook_timer));
|
||||
if (!new_hook_timer)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -623,10 +623,10 @@ hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read,
|
|||
if ((fd < 0) || hook_search_fd (fd))
|
||||
return NULL;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_fd = (struct t_hook_fd *)malloc (sizeof (struct t_hook_fd));
|
||||
new_hook_fd = malloc (sizeof (*new_hook_fd));
|
||||
if (!new_hook_fd)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -740,10 +740,10 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
|
|||
struct t_hook *new_hook;
|
||||
struct t_hook_print *new_hook_print;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_print = (struct t_hook_print *)malloc (sizeof (struct t_hook_print));
|
||||
new_hook_print = malloc (sizeof (*new_hook_print));
|
||||
if (!new_hook_print)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -883,10 +883,10 @@ hook_signal (struct t_weechat_plugin *plugin, char *signal,
|
|||
if (!signal || !signal[0])
|
||||
return NULL;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_signal = (struct t_hook_signal *)malloc (sizeof (struct t_hook_signal));
|
||||
new_hook_signal = malloc (sizeof (*new_hook_signal));
|
||||
if (!new_hook_signal)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -947,10 +947,10 @@ hook_config (struct t_weechat_plugin *plugin, char *type, char *option,
|
|||
struct t_hook *new_hook;
|
||||
struct t_hook_config *new_hook_config;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_config = (struct t_hook_config *)malloc (sizeof (struct t_hook_config));
|
||||
new_hook_config = malloc (sizeof (*new_hook_config));
|
||||
if (!new_hook_config)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -1020,10 +1020,10 @@ hook_completion (struct t_weechat_plugin *plugin, char *completion,
|
|||
if (!completion || !completion[0] || strchr (completion, ' '))
|
||||
return NULL;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_completion = (struct t_hook_completion *)malloc (sizeof (struct t_hook_completion));
|
||||
new_hook_completion = malloc (sizeof (*new_hook_completion));
|
||||
if (!new_hook_completion)
|
||||
{
|
||||
free (new_hook);
|
||||
|
@ -1092,10 +1092,10 @@ hook_modifier (struct t_weechat_plugin *plugin, char *modifier,
|
|||
if (!modifier || !modifier[0])
|
||||
return NULL;
|
||||
|
||||
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_modifier = (struct t_hook_modifier *)malloc (sizeof (struct t_hook_modifier));
|
||||
new_hook_modifier = malloc (sizeof (*new_hook_modifier));
|
||||
if (!new_hook_modifier)
|
||||
{
|
||||
free (new_hook);
|
||||
|
|
|
@ -122,9 +122,9 @@ input_exec_command (struct t_gui_buffer *buffer, char *string,
|
|||
/*if (cfg_irc_send_unknown_commands)
|
||||
{
|
||||
if (ptr_args)
|
||||
unknown_command = (char *)malloc ((strlen (command + 1) + 1 + strlen (ptr_args) + 1) * sizeof (char));
|
||||
unknown_command = malloc (strlen (command + 1) + 1 + strlen (ptr_args) + 1);
|
||||
else
|
||||
unknown_command = (char *)malloc ((strlen (command + 1) + 1) * sizeof (char));
|
||||
unknown_command = malloc (strlen (command + 1) + 1);
|
||||
|
||||
if (unknown_command)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ weelist_new ()
|
|||
{
|
||||
struct t_weelist *new_weelist;
|
||||
|
||||
new_weelist = (struct t_weelist *)malloc (sizeof (struct t_weelist));
|
||||
new_weelist = malloc (sizeof (*new_weelist));
|
||||
if (new_weelist)
|
||||
{
|
||||
new_weelist->items = NULL;
|
||||
|
@ -146,7 +146,8 @@ weelist_add (struct t_weelist *weelist, char *data, char *where)
|
|||
if (!weelist || !data || !data[0] || !where || !where[0])
|
||||
return NULL;
|
||||
|
||||
if ((new_item = ((struct t_weelist_item *)malloc (sizeof (struct t_weelist_item)))))
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
new_item->data = strdup (data);
|
||||
weelist_insert (weelist, new_item, where);
|
||||
|
|
|
@ -63,8 +63,7 @@ log_open (char *filename, char *mode)
|
|||
else
|
||||
{
|
||||
filename_length = strlen (weechat_home) + 64;
|
||||
weechat_log_filename =
|
||||
(char *)malloc (filename_length * sizeof (char));
|
||||
weechat_log_filename = malloc (filename_length);
|
||||
snprintf (weechat_log_filename, filename_length,
|
||||
"%s/%s", weechat_home, WEECHAT_LOG_NAME);
|
||||
}
|
||||
|
@ -204,7 +203,7 @@ log_crash_rename ()
|
|||
log_close ();
|
||||
|
||||
length = strlen (weechat_home) + 128;
|
||||
new_name = (char *)malloc (length * sizeof (char));
|
||||
new_name = malloc (length);
|
||||
if (new_name)
|
||||
{
|
||||
time_now = time (NULL);
|
||||
|
|
|
@ -59,7 +59,7 @@ string_strndup (char *string, int length)
|
|||
if ((int)strlen (string) < length)
|
||||
return strdup (string);
|
||||
|
||||
result = (char *)malloc ((length + 1) * sizeof (char));
|
||||
result = malloc (length + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
@ -361,7 +361,7 @@ string_replace (char *string, char *search, char *replace)
|
|||
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
|
||||
|
||||
/* allocate new string */
|
||||
new_string = (char *)malloc (length_new * sizeof (char));
|
||||
new_string = malloc (length_new);
|
||||
if (!new_string)
|
||||
return strdup (string);
|
||||
|
||||
|
@ -478,7 +478,7 @@ string_convert_hex_chars (char *string)
|
|||
int pos_output;
|
||||
long number;
|
||||
|
||||
output = (char *)malloc ((strlen (string) + 1) * sizeof (char));
|
||||
output = malloc (strlen (string) + 1);
|
||||
if (output)
|
||||
{
|
||||
pos_output = 0;
|
||||
|
@ -587,7 +587,7 @@ string_explode (char *string, char *separators, int keep_eol,
|
|||
if ((num_items_max != 0) && (n_items > num_items_max))
|
||||
n_items = num_items_max;
|
||||
|
||||
array = (char **)malloc ((n_items + 1) * sizeof (char *));
|
||||
array = malloc ((n_items + 1) * sizeof (array[0]));
|
||||
|
||||
ptr1 = string2;
|
||||
ptr2 = string2;
|
||||
|
@ -632,8 +632,7 @@ string_explode (char *string, char *separators, int keep_eol,
|
|||
}
|
||||
else
|
||||
{
|
||||
array[i] =
|
||||
(char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char));
|
||||
array[i] = malloc (ptr2 - ptr1 + 1);
|
||||
strncpy (array[i], ptr1, ptr2 - ptr1);
|
||||
array[i][ptr2 - ptr1] = '\0';
|
||||
}
|
||||
|
@ -694,7 +693,7 @@ string_build_with_exploded (char **exploded_string, char *separator)
|
|||
length += strlen (exploded_string[i]) + length_separator;
|
||||
}
|
||||
|
||||
result = (char *)malloc ((length + 1) * sizeof (char));
|
||||
result = malloc (length + 1);
|
||||
result[0] = '\0';
|
||||
|
||||
for (i = 0; exploded_string[i]; i++)
|
||||
|
@ -733,11 +732,11 @@ string_split_command (char *command, char separator)
|
|||
ptr = ++p;
|
||||
}
|
||||
|
||||
array = (char **)malloc ((nb_substr + 1) * sizeof (char *));
|
||||
array = malloc ((nb_substr + 1) * sizeof (array[0]));
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
buffer = (char *)malloc ((strlen(command) + 1) * sizeof (char));
|
||||
buffer = malloc (strlen(command) + 1);
|
||||
if (!buffer)
|
||||
{
|
||||
free (array);
|
||||
|
@ -787,7 +786,7 @@ string_split_command (char *command, char separator)
|
|||
|
||||
free (buffer);
|
||||
|
||||
array = (char **)realloc (array, (arr_idx + 1) * sizeof(char *));
|
||||
array = realloc (array, (arr_idx + 1) * sizeof(array[0]));
|
||||
|
||||
return array;
|
||||
}
|
||||
|
@ -838,7 +837,7 @@ string_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
|||
ptr_inbuf = inbuf;
|
||||
inbytesleft = strlen (inbuf);
|
||||
outbytesleft = inbytesleft * 4;
|
||||
outbuf = (char *)malloc ((outbytesleft + 2) * sizeof (char));
|
||||
outbuf = malloc (outbytesleft + 2);
|
||||
ptr_outbuf = outbuf;
|
||||
ptr_inbuf_shift = NULL;
|
||||
done = 0;
|
||||
|
|
|
@ -600,7 +600,7 @@ session_read_str (FILE *file, char **string)
|
|||
|
||||
if (string)
|
||||
{
|
||||
(*string) = (char *)malloc ((length + 1) * sizeof (char));
|
||||
(*string) = malloc (length + 1);
|
||||
if (!(*string))
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ utf8_strlen_screen (char *string)
|
|||
return utf8_strlen (string);
|
||||
|
||||
num_char = mbstowcs (NULL, string, 0) + 1;
|
||||
wstring = (wchar_t *)malloc ((num_char + 1) * sizeof (wchar_t));
|
||||
wstring = malloc ((num_char + 1) * sizeof (wstring[0]));
|
||||
if (!wstring)
|
||||
return utf8_strlen (string);
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ util_search_full_lib_name (char *filename, char *sys_directory)
|
|||
if (CONFIG_STRING(config_plugins_extension)
|
||||
&& CONFIG_STRING(config_plugins_extension)[0])
|
||||
length += strlen (CONFIG_STRING(config_plugins_extension));
|
||||
name_with_ext = (char *)malloc (length * sizeof (char));
|
||||
name_with_ext = malloc (length);
|
||||
if (!name_with_ext)
|
||||
return strdup (filename);
|
||||
strcpy (name_with_ext, filename);
|
||||
|
@ -234,7 +234,7 @@ util_search_full_lib_name (char *filename, char *sys_directory)
|
|||
/* try WeeChat user's dir */
|
||||
length = strlen (weechat_home) + strlen (name_with_ext) +
|
||||
strlen (sys_directory) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (!final_name)
|
||||
{
|
||||
free (name_with_ext);
|
||||
|
@ -252,7 +252,7 @@ util_search_full_lib_name (char *filename, char *sys_directory)
|
|||
/* try WeeChat global lib dir */
|
||||
length = strlen (WEECHAT_LIBDIR) + strlen (name_with_ext) +
|
||||
strlen (sys_directory) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (!final_name)
|
||||
{
|
||||
free (name_with_ext);
|
||||
|
|
|
@ -357,8 +357,7 @@ weechat_create_home_dirs ()
|
|||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
dir_length = strlen (ptr_home) + 10;
|
||||
weechat_home =
|
||||
(char *)malloc (dir_length * sizeof (char));
|
||||
weechat_home = malloc (dir_length);
|
||||
if (!weechat_home)
|
||||
{
|
||||
string_iconv_fprintf (stderr,
|
||||
|
|
|
@ -158,7 +158,7 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
|||
if (!gui_init_ok)
|
||||
return 0;
|
||||
|
||||
new_bar_window = (struct t_gui_bar_window *) malloc (sizeof (struct t_gui_bar_window));
|
||||
new_bar_window = malloc (sizeof (*new_bar_window));
|
||||
if (new_bar_window)
|
||||
{
|
||||
new_bar_window->bar = bar;
|
||||
|
|
|
@ -159,7 +159,7 @@ gui_color_assign (t_gui_color **color, char *fg_and_bg)
|
|||
|
||||
if (!(*color))
|
||||
{
|
||||
*color = (t_gui_color *)malloc (sizeof (t_gui_color));
|
||||
*color = malloc (sizeof (**color));
|
||||
if (!(*color))
|
||||
return;
|
||||
*color->foreground = 0;
|
||||
|
@ -228,7 +228,7 @@ gui_color_assign (t_gui_color **color, char *fg_and_bg)
|
|||
|
||||
if (*color->string)
|
||||
free (*color->string);
|
||||
*color->string = (char *)malloc (4 * sizeof (char));
|
||||
*color->string = malloc (4);
|
||||
if (*color->string)
|
||||
snprintf (*color->string, 4,
|
||||
"%s%02d",
|
||||
|
@ -271,14 +271,14 @@ gui_color_build (int number, int foreground, int background)
|
|||
{
|
||||
struct t_gui_color *new_color;
|
||||
|
||||
new_color = (struct t_gui_color *)malloc (sizeof (struct t_gui_color));
|
||||
new_color = malloc (sizeof (*new_color));
|
||||
if (!new_color)
|
||||
return NULL;
|
||||
|
||||
new_color->foreground = gui_weechat_colors[foreground].foreground;
|
||||
new_color->background = gui_weechat_colors[background].foreground;
|
||||
new_color->attributes = gui_weechat_colors[foreground].attributes;
|
||||
new_color->string = (char *)malloc (4 * sizeof (char));
|
||||
new_color->string = malloc (4);
|
||||
if (new_color->string)
|
||||
snprintf (new_color->string, 4,
|
||||
"%s%02d",
|
||||
|
|
|
@ -75,7 +75,7 @@ gui_window_objects_init (struct t_gui_window *window)
|
|||
{
|
||||
struct t_gui_curses_objects *new_objects;
|
||||
|
||||
if ((new_objects = (struct t_gui_curses_objects *)malloc (sizeof (struct t_gui_curses_objects))))
|
||||
if ((new_objects = malloc (sizeof (*new_objects))))
|
||||
{
|
||||
window->gui_objects = new_objects;
|
||||
GUI_CURSES(window)->win_title = NULL;
|
||||
|
|
|
@ -68,7 +68,7 @@ gui_window_objects_init (struct t_gui_window *window)
|
|||
{
|
||||
struct t_gui_gtk_objects *new_objects;
|
||||
|
||||
if ((new_objects = (struct t_gui_gtk_objects *)malloc (sizeof (struct t_gui_gtk_objects))))
|
||||
if ((new_objects = malloc (sizeof (*new_objects))))
|
||||
{
|
||||
window->gui_objects = new_objects;
|
||||
GUI_GTK(window)->textview_chat = NULL;
|
||||
|
|
|
@ -63,7 +63,7 @@ gui_action_clipboard_copy (char *buffer, int size)
|
|||
if (gui_input_clipboard != NULL)
|
||||
free (gui_input_clipboard);
|
||||
|
||||
gui_input_clipboard = (char *)malloc((size + 1) * sizeof(*gui_input_clipboard));
|
||||
gui_input_clipboard = malloc((size + 1) * sizeof(*gui_input_clipboard));
|
||||
|
||||
if (gui_input_clipboard)
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, char *name,
|
|||
return NULL;
|
||||
|
||||
/* create bar item */
|
||||
new_bar_item = (struct t_gui_bar_item *) malloc (sizeof (struct t_gui_bar_item));
|
||||
new_bar_item = malloc (sizeof (*new_bar_item));
|
||||
if (new_bar_item)
|
||||
{
|
||||
new_bar_item->plugin = plugin;
|
||||
|
@ -540,7 +540,7 @@ gui_bar_item_hook (char *signal, char *item)
|
|||
{
|
||||
struct t_gui_bar_item_hook *bar_item_hook;
|
||||
|
||||
bar_item_hook = (struct t_gui_bar_item_hook *)malloc (sizeof (struct t_gui_bar_item_hook));
|
||||
bar_item_hook = malloc (sizeof (*bar_item_hook));
|
||||
if (bar_item_hook)
|
||||
{
|
||||
bar_item_hook->hook = hook_signal (NULL, signal,
|
||||
|
|
|
@ -137,7 +137,7 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name, char *type,
|
|||
return NULL;
|
||||
|
||||
/* create bar */
|
||||
new_bar = (struct t_gui_bar *) malloc (sizeof (struct t_gui_bar));
|
||||
new_bar = malloc (sizeof (*new_bar));
|
||||
if (new_bar)
|
||||
{
|
||||
new_bar->plugin = plugin;
|
||||
|
|
|
@ -88,7 +88,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
|
|||
}
|
||||
|
||||
/* create new buffer */
|
||||
new_buffer = (struct t_gui_buffer *)(malloc (sizeof (struct t_gui_buffer)));
|
||||
new_buffer = malloc (sizeof (*new_buffer));
|
||||
if (new_buffer)
|
||||
{
|
||||
/* init buffer */
|
||||
|
@ -133,8 +133,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
|
|||
new_buffer->input_callback_data = input_callback_data;
|
||||
new_buffer->input_nick = NULL;
|
||||
new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE;
|
||||
new_buffer->input_buffer = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE * sizeof (char));
|
||||
new_buffer->input_buffer_color_mask = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE * sizeof (char));
|
||||
new_buffer->input_buffer = malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
|
||||
new_buffer->input_buffer_color_mask = malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
|
||||
new_buffer->input_buffer[0] = '\0';
|
||||
new_buffer->input_buffer_color_mask[0] = '\0';
|
||||
new_buffer->input_buffer_size = 0;
|
||||
|
@ -144,7 +144,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
|
|||
new_buffer->input_refresh_needed = 1;
|
||||
|
||||
/* init completion */
|
||||
new_completion = (struct t_gui_completion *)malloc (sizeof (struct t_gui_completion));
|
||||
new_completion = malloc (sizeof (*new_completion));
|
||||
if (new_completion)
|
||||
{
|
||||
new_buffer->completion = new_completion;
|
||||
|
|
|
@ -603,7 +603,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
|
|||
{
|
||||
struct t_gui_line *new_line, *ptr_line;
|
||||
|
||||
new_line = (struct t_gui_line *)malloc (sizeof (struct t_gui_line));
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
{
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
|
|
|
@ -81,7 +81,7 @@ gui_color_decode (unsigned char *string)
|
|||
int out_length, out_pos, length;
|
||||
|
||||
out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length * sizeof (unsigned char));
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ gui_completion_strdup_alphanum (char *string)
|
|||
{
|
||||
char *result, *pos;
|
||||
|
||||
result = (char *)malloc ((strlen (string) + 1) * sizeof (char));
|
||||
result = malloc (strlen (string) + 1);
|
||||
pos = result;
|
||||
while (string[0])
|
||||
{
|
||||
|
@ -334,7 +334,7 @@ gui_completion_list_add_filename (struct t_gui_completion *completion)
|
|||
char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' };
|
||||
|
||||
buffer_len = PATH_MAX;
|
||||
buffer = (char *)malloc (buffer_len * sizeof (char));
|
||||
buffer = malloc (buffer_len);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
@ -971,7 +971,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data,
|
|||
if (pos_start <= pos_end)
|
||||
{
|
||||
completion->position_replace = pos_start;
|
||||
completion->base_word = (char *)malloc ((pos_end - pos_start + 2) * sizeof (char));
|
||||
completion->base_word = malloc (pos_end - pos_start + 2);
|
||||
for (i = pos_start; i <= pos_end; i++)
|
||||
completion->base_word[i - pos_start] = data[i];
|
||||
completion->base_word[pos_end - pos_start + 1] = '\0';
|
||||
|
@ -996,7 +996,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data,
|
|||
if (data[pos_end] == ' ')
|
||||
pos_end--;
|
||||
|
||||
completion->base_command = (char *)malloc ((pos_end - pos_start + 2) * sizeof (char));
|
||||
completion->base_command = malloc (pos_end - pos_start + 2);
|
||||
for (i = pos_start; i <= pos_end; i++)
|
||||
completion->base_command[i - pos_start] = data[i];
|
||||
completion->base_command[pos_end - pos_start + 1] = '\0';
|
||||
|
|
|
@ -271,7 +271,7 @@ gui_filter_new (char *buffer, char *tags, char *regex)
|
|||
if (!regex_prefix)
|
||||
return NULL;
|
||||
|
||||
regex1 = (regex_t *)malloc (sizeof (regex_t));
|
||||
regex1 = malloc (sizeof (*regex1));
|
||||
if (regex1)
|
||||
{
|
||||
if (regcomp (regex1, regex_prefix,
|
||||
|
@ -283,7 +283,7 @@ gui_filter_new (char *buffer, char *tags, char *regex)
|
|||
}
|
||||
}
|
||||
|
||||
regex2 = (regex_t *)malloc (sizeof (regex_t));
|
||||
regex2 = malloc (sizeof (*regex2));
|
||||
if (regex2)
|
||||
{
|
||||
if (regcomp (regex2, pos_regex_message,
|
||||
|
@ -301,7 +301,7 @@ gui_filter_new (char *buffer, char *tags, char *regex)
|
|||
}
|
||||
|
||||
/* create new filter */
|
||||
new_filter = (struct t_gui_filter *)(malloc (sizeof (struct t_gui_filter)));
|
||||
new_filter = (malloc (sizeof (*new_filter)));
|
||||
if (new_filter)
|
||||
{
|
||||
/* init filter */
|
||||
|
|
|
@ -55,7 +55,7 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, char *string)
|
|||
|| (buffer->history
|
||||
&& (strcmp (buffer->history->text, string) != 0)))
|
||||
{
|
||||
new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
|
||||
new_history = malloc (sizeof (*new_history));
|
||||
if (new_history)
|
||||
{
|
||||
new_history->text = strdup (string);
|
||||
|
@ -105,7 +105,7 @@ gui_history_global_add (char *string)
|
|||
|| (history_global
|
||||
&& (strcmp (history_global->text, string) != 0)))
|
||||
{
|
||||
new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
|
||||
new_history = malloc (sizeof (*new_history));
|
||||
if (new_history)
|
||||
{
|
||||
new_history->text = strdup (string);
|
||||
|
|
|
@ -217,7 +217,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer, int priority,
|
|||
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
|
||||
}
|
||||
|
||||
new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist));
|
||||
new_hotlist = malloc (sizeof (*new_hotlist));
|
||||
if (!new_hotlist)
|
||||
{
|
||||
log_printf (_("Error: not enough memory to add a buffer to "
|
||||
|
@ -249,7 +249,7 @@ gui_hotlist_dup (struct t_gui_hotlist *hotlist)
|
|||
{
|
||||
struct t_gui_hotlist *new_hotlist;
|
||||
|
||||
new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist));
|
||||
new_hotlist = malloc (sizeof (*new_hotlist));
|
||||
if (new_hotlist)
|
||||
{
|
||||
new_hotlist->priority = hotlist->priority;
|
||||
|
|
|
@ -59,7 +59,7 @@ gui_infobar_printf (int delay, int color, char *message, ...)
|
|||
vsnprintf (buf, sizeof (buf) - 1, message, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
ptr_infobar = (struct t_gui_infobar *)malloc (sizeof (struct t_gui_infobar));
|
||||
ptr_infobar = malloc (sizeof (*ptr_infobar));
|
||||
if (ptr_infobar)
|
||||
{
|
||||
buf2 = (char *)gui_color_decode ((unsigned char *)buf);
|
||||
|
|
|
@ -56,9 +56,9 @@ gui_input_optimize_size (struct t_gui_buffer *buffer)
|
|||
if (buffer->input_buffer_alloc != optimal_size)
|
||||
{
|
||||
buffer->input_buffer_alloc = optimal_size;
|
||||
buffer->input_buffer = realloc (buffer->input_buffer, optimal_size * sizeof (char));
|
||||
buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
|
||||
buffer->input_buffer_color_mask = realloc (buffer->input_buffer_color_mask,
|
||||
optimal_size * sizeof (char));
|
||||
optimal_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ gui_input_insert_string (struct t_gui_buffer *buffer, char *string, int pos)
|
|||
|
||||
buffer->input_buffer_pos += length;
|
||||
|
||||
string2 = (char *)malloc ((size + 2) * sizeof (char));
|
||||
string2 = malloc (size + 2);
|
||||
if (string2)
|
||||
{
|
||||
snprintf (string2, size + 2, "*%s", string);
|
||||
|
|
|
@ -243,7 +243,7 @@ gui_keyboard_get_internal_code (char *key)
|
|||
{
|
||||
char *result;
|
||||
|
||||
if ((result = (char *)malloc ((strlen (key) + 1) * sizeof (char))))
|
||||
if ((result = malloc (strlen (key) + 1)))
|
||||
{
|
||||
result[0] = '\0';
|
||||
while (key[0])
|
||||
|
@ -286,7 +286,7 @@ gui_keyboard_get_expanded_name (char *key)
|
|||
{
|
||||
char *result;
|
||||
|
||||
if ((result = (char *)malloc (((strlen (key) * 5) + 1) * sizeof (char))))
|
||||
if ((result = malloc ((strlen (key) * 5) + 1)))
|
||||
{
|
||||
result[0] = '\0';
|
||||
while (key[0])
|
||||
|
@ -390,7 +390,7 @@ gui_keyboard_new (char *key, char *command, t_gui_key_func *function,
|
|||
char *internal_code;
|
||||
int length;
|
||||
|
||||
if ((new_key = (struct t_gui_key *)malloc (sizeof (struct t_gui_key))))
|
||||
if ((new_key = malloc (sizeof (*new_key))))
|
||||
{
|
||||
internal_code = gui_keyboard_get_internal_code (key);
|
||||
new_key->key = (internal_code) ? strdup (internal_code) : strdup (key);
|
||||
|
@ -736,7 +736,7 @@ gui_keyboard_buffer_optimize ()
|
|||
if (gui_keyboard_buffer_alloc != optimal_size)
|
||||
{
|
||||
gui_keyboard_buffer_alloc = optimal_size;
|
||||
gui_keyboard_buffer = realloc (gui_keyboard_buffer, optimal_size * sizeof (char));
|
||||
gui_keyboard_buffer = realloc (gui_keyboard_buffer, optimal_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ gui_keyboard_buffer_reset ()
|
|||
{
|
||||
gui_keyboard_buffer_alloc = GUI_KEYBOARD_BUFFER_BLOCK_SIZE;
|
||||
gui_keyboard_buffer_size = 0;
|
||||
gui_keyboard_buffer = (int *)malloc (gui_keyboard_buffer_alloc);
|
||||
gui_keyboard_buffer = malloc (gui_keyboard_buffer_alloc);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -157,7 +157,7 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
|
|||
if (!name || gui_nicklist_search_group (buffer, parent_group, name))
|
||||
return NULL;
|
||||
|
||||
new_group = (struct t_gui_nick_group *)malloc (sizeof (struct t_gui_nick_group));
|
||||
new_group = malloc (sizeof (*new_group));
|
||||
if (!new_group)
|
||||
return NULL;
|
||||
|
||||
|
@ -304,7 +304,7 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer,
|
|||
if (!name || gui_nicklist_search_nick (buffer, NULL, name))
|
||||
return NULL;
|
||||
|
||||
new_nick = (struct t_gui_nick *)malloc (sizeof (struct t_gui_nick));
|
||||
new_nick = malloc (sizeof (*new_nick));
|
||||
if (!new_nick)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ struct t_gui_window_tree *gui_windows_tree = NULL; /* windows tree */
|
|||
int
|
||||
gui_window_tree_init (struct t_gui_window *window)
|
||||
{
|
||||
gui_windows_tree = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
|
||||
gui_windows_tree = malloc (sizeof (*gui_windows_tree));
|
||||
if (!gui_windows_tree)
|
||||
return 0;
|
||||
gui_windows_tree->parent_node = NULL;
|
||||
|
@ -137,10 +137,10 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
|
|||
|
||||
if (parent)
|
||||
{
|
||||
child1 = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
|
||||
child1 = malloc (sizeof (*child1));
|
||||
if (!child1)
|
||||
return NULL;
|
||||
child2 = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
|
||||
child2 = malloc (sizeof (*child2));
|
||||
if (!child2)
|
||||
{
|
||||
free (child1);
|
||||
|
@ -186,7 +186,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
|
|||
ptr_leaf = gui_windows_tree;
|
||||
}
|
||||
|
||||
if ((new_window = (struct t_gui_window *)(malloc (sizeof (struct t_gui_window)))))
|
||||
if ((new_window = (malloc (sizeof (*new_window)))))
|
||||
{
|
||||
if (!gui_window_objects_init (new_window))
|
||||
{
|
||||
|
|
|
@ -78,12 +78,12 @@ alias_add_word (char **alias, int *length, char *word)
|
|||
|
||||
if (*alias == NULL)
|
||||
{
|
||||
*alias = (char *)malloc ((length_word + 1) * sizeof (char));
|
||||
*alias = malloc (length_word + 1);
|
||||
strcpy (*alias, word);
|
||||
}
|
||||
else
|
||||
{
|
||||
*alias = realloc (*alias, (strlen (*alias) + length_word + 1) * sizeof (char));
|
||||
*alias = realloc (*alias, strlen (*alias) + length_word + 1);
|
||||
strcat (*alias, word);
|
||||
}
|
||||
*length += length_word;
|
||||
|
@ -218,7 +218,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
|||
weechat_command (buffer, args_replaced);
|
||||
else
|
||||
{
|
||||
alias_command = (char *)malloc ((1 + strlen(args_replaced) + 1) * sizeof (char));
|
||||
alias_command = malloc (1 + strlen(args_replaced) + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
strcpy (alias_command, "/");
|
||||
|
@ -238,7 +238,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
|||
length1 = strlen (*ptr_cmd);
|
||||
length2 = strlen (argv_eol[1]);
|
||||
|
||||
alias_command = (char *)malloc ((1 + length1 + 1 + length2 + 1) * sizeof (char));
|
||||
alias_command = malloc (1 + length1 + 1 + length2 + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
if (*ptr_cmd[0] != '/')
|
||||
|
@ -260,7 +260,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
|||
(void) weechat_command(buffer, *ptr_cmd);
|
||||
else
|
||||
{
|
||||
alias_command = (char *)malloc ((1 + strlen (*ptr_cmd) + 1) * sizeof (char));
|
||||
alias_command = malloc (1 + strlen (*ptr_cmd) + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
strcpy (alias_command, "/");
|
||||
|
@ -306,7 +306,7 @@ alias_new (char *name, char *command)
|
|||
return ptr_alias;
|
||||
}
|
||||
|
||||
new_alias = (struct t_alias *)malloc (sizeof (struct t_alias));
|
||||
new_alias = malloc (sizeof (*new_alias));
|
||||
if (new_alias)
|
||||
{
|
||||
new_hook = weechat_hook_command (name, "[alias]", NULL, NULL, NULL,
|
||||
|
|
|
@ -53,7 +53,7 @@ weechat_aspell_new_speller (void)
|
|||
{
|
||||
aspell_speller_t *s;
|
||||
|
||||
s = (aspell_speller_t *)malloc (sizeof (aspell_speller_t));
|
||||
s = malloc (sizeof (*s));
|
||||
if (!s)
|
||||
{
|
||||
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
|
||||
|
@ -208,7 +208,7 @@ weechat_aspell_new_config (void)
|
|||
{
|
||||
aspell_config_t *c;
|
||||
|
||||
c = (aspell_config_t *)malloc (sizeof (aspell_config_t));
|
||||
c = malloc (sizeof (*c));
|
||||
if (!c)
|
||||
{
|
||||
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
|
||||
|
@ -833,7 +833,7 @@ weechat_aspell_config_save (void)
|
|||
if (found == 0)
|
||||
{
|
||||
n = strlen (servers) + strlen (p->server) + 2;
|
||||
servers = (char *)realloc (servers, n * sizeof (char));
|
||||
servers = realloc (servers, n);
|
||||
strcat (servers, " ");
|
||||
strcat (servers, p->server);
|
||||
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, "servers", servers);
|
||||
|
@ -853,13 +853,13 @@ weechat_aspell_config_save (void)
|
|||
else
|
||||
{
|
||||
n = strlen (channels) + strlen (q->channel) + 2;
|
||||
channels = (char *)realloc (channels, n * sizeof (char));
|
||||
channels = realloc (channels, n);
|
||||
strcat (channels, " ");
|
||||
strcat (channels, q->channel);
|
||||
}
|
||||
|
||||
n = 7 + strlen (p->server) + strlen (q->channel);
|
||||
option = (char *)malloc (n * sizeof (char));
|
||||
option = malloc (n);
|
||||
snprintf (option, n, "lang_%s_%s", p->server, q->channel);
|
||||
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, q->speller->lang);
|
||||
free (option);
|
||||
|
@ -869,7 +869,7 @@ weechat_aspell_config_save (void)
|
|||
if (channels)
|
||||
{
|
||||
n = 10 + strlen (p->server);
|
||||
option = (char *)malloc (n * sizeof (char));
|
||||
option = malloc (n);
|
||||
snprintf (option, n, "channels_%s", p->server);
|
||||
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, channels);
|
||||
free (option);
|
||||
|
@ -904,7 +904,7 @@ weechat_aspell_config_load(void)
|
|||
for (i=0; i<s; i++)
|
||||
{
|
||||
n = 10 + strlen (servers_list[i]);
|
||||
option_s = (char *)malloc (n * sizeof (char));
|
||||
option_s = malloc (n);
|
||||
snprintf (option_s, n, "channels_%s", servers_list[i]);
|
||||
|
||||
channels = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_s);
|
||||
|
@ -916,7 +916,7 @@ weechat_aspell_config_load(void)
|
|||
for (j=0; j<c; j++)
|
||||
{
|
||||
n = 7 + strlen (servers_list[i]) + strlen (channels_list[j]);
|
||||
option_l = (char *)malloc (n * sizeof (char));
|
||||
option_l = malloc (n);
|
||||
snprintf (option_l, n, "lang_%s_%s", servers_list[i], channels_list[j]);
|
||||
|
||||
lang = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_l);
|
||||
|
@ -1179,7 +1179,7 @@ weechat_aspell_clean_word (char *word, int *offset)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
w = (char *)malloc ((len+1) * sizeof(char));
|
||||
w = malloc (len+1);
|
||||
|
||||
if (w) {
|
||||
memcpy (w, buffer + *offset, len);
|
||||
|
|
|
@ -110,7 +110,7 @@ charset_new (char *name, char *charset)
|
|||
return ptr_charset;
|
||||
}
|
||||
|
||||
new_charset = (struct t_charset *)malloc (sizeof (struct t_charset));
|
||||
new_charset = malloc (sizeof (*new_charset));
|
||||
{
|
||||
new_charset->name = strdup (name);
|
||||
new_charset->charset = strdup (charset);
|
||||
|
@ -486,7 +486,7 @@ charset_get (char *type, char *name)
|
|||
int length;
|
||||
|
||||
length = strlen (type) + 1 + strlen (name) + 1;
|
||||
option_name = (char *)malloc (length * sizeof (char));
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s",
|
||||
|
@ -585,7 +585,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
|||
&& (weechat_strncasecmp (argv[1], "encode.", 7) != 0))
|
||||
{
|
||||
length = strlen (argv[1]) + strlen ("decode.") + 1;
|
||||
option_name = (char *)malloc (length * sizeof (char));
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
{
|
||||
rc = 1;
|
||||
|
|
|
@ -78,8 +78,7 @@ fifo_create ()
|
|||
if (!fifo_filename)
|
||||
{
|
||||
filename_length = strlen (weechat_home) + 64;
|
||||
fifo_filename = (char *)malloc (filename_length *
|
||||
sizeof (char));
|
||||
fifo_filename = malloc (filename_length);
|
||||
snprintf (fifo_filename, filename_length,
|
||||
"%s/weechat_fifo_%d",
|
||||
weechat_home, (int) getpid());
|
||||
|
@ -240,8 +239,8 @@ fifo_read ()
|
|||
ptr_buf = buffer;
|
||||
if (fifo_unterminated)
|
||||
{
|
||||
buf2 = (char *)malloc ((strlen (fifo_unterminated) +
|
||||
strlen (buffer) + 1) * sizeof (char));
|
||||
buf2 = malloc (strlen (fifo_unterminated) +
|
||||
strlen (buffer) + 1);
|
||||
if (buf2)
|
||||
{
|
||||
strcpy (buf2, fifo_unterminated);
|
||||
|
|
|
@ -47,7 +47,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
|||
struct t_gui_buffer *new_buffer;
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = (struct t_irc_channel *)malloc (sizeof (struct t_irc_channel))) == NULL)
|
||||
if ((new_channel = malloc (sizeof (*new_channel))) == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: cannot allocate new channel"),
|
||||
|
@ -411,7 +411,7 @@ irc_channel_get_notify_level (struct t_irc_server *server,
|
|||
&& (server_default_notify == 1))
|
||||
server_default_notify = 2;
|
||||
|
||||
name = (char *)malloc ((strlen (channel->name) + 2) * sizeof (char));
|
||||
name = malloc (strlen (channel->name) + 2);
|
||||
strcpy (name, channel->name);
|
||||
strcat (name, ":");
|
||||
pos = strstr (server->notify_levels, name);
|
||||
|
|
|
@ -52,7 +52,7 @@ irc_color_decode (unsigned char *string, int keep_irc_colors,
|
|||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length * sizeof (unsigned char));
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
@ -209,7 +209,7 @@ irc_color_decode_for_user_entry (unsigned char *string)
|
|||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length * sizeof (unsigned char));
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
@ -278,7 +278,7 @@ irc_color_encode (unsigned char *string, int keep_colors)
|
|||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length * sizeof (unsigned char));
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ irc_command_mode_nicks (struct t_irc_server *server, char *channel,
|
|||
for (i = 1; i < argc; i++)
|
||||
length += strlen (argv[i]) + 1;
|
||||
length += strlen (channel) + (argc * strlen (mode)) + 32;
|
||||
command = (char *)malloc (length * sizeof (char));
|
||||
command = malloc (length);
|
||||
if (command)
|
||||
{
|
||||
snprintf (command, length, "MODE %s %s", channel, set);
|
||||
|
@ -258,7 +258,7 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
|
|||
{
|
||||
if (server->away_message)
|
||||
free (server->away_message);
|
||||
server->away_message = (char *)malloc ((strlen (arguments) + 1) * sizeof (char));
|
||||
server->away_message = malloc (strlen (arguments) + 1);
|
||||
if (server->away_message)
|
||||
strcpy (server->away_message, arguments);
|
||||
|
||||
|
@ -1566,7 +1566,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
|
|||
|
||||
if (argc > 1)
|
||||
{
|
||||
ptr_server->cmd_list_regexp = (regex_t *)malloc (sizeof (regex_t));
|
||||
ptr_server->cmd_list_regexp = malloc (sizeof (*ptr_server->cmd_list_regexp));
|
||||
if (ptr_server->cmd_list_regexp)
|
||||
{
|
||||
if ((ret = regcomp (ptr_server->cmd_list_regexp,
|
||||
|
|
|
@ -232,7 +232,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion,
|
|||
{
|
||||
length = strlen (ptr_nick->name) + 1 +
|
||||
strlen (ptr_nick->host) + 1;
|
||||
buf = (char *)malloc (length * sizeof (char));
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
snprintf (buf, length, "%s!%s",
|
||||
|
|
|
@ -169,9 +169,9 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
|
|||
return;
|
||||
}
|
||||
|
||||
ptr_dcc->local_filename = (char *)malloc ((strlen (dir2) +
|
||||
strlen (ptr_dcc->nick) +
|
||||
strlen (ptr_dcc->filename) + 4) * sizeof (char));
|
||||
ptr_dcc->local_filename = malloc (strlen (dir2) +
|
||||
strlen (ptr_dcc->nick) +
|
||||
strlen (ptr_dcc->filename) + 4);
|
||||
if (!ptr_dcc->local_filename)
|
||||
return;
|
||||
|
||||
|
@ -203,7 +203,7 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
|
|||
return;
|
||||
}
|
||||
|
||||
filename2 = (char *)malloc ((strlen (ptr_dcc->local_filename) + 16) * sizeof (char));
|
||||
filename2 = malloc (strlen (ptr_dcc->local_filename) + 16);
|
||||
if (!filename2)
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
|
@ -722,7 +722,7 @@ irc_dcc_alloc ()
|
|||
struct t_irc_dcc *new_dcc;
|
||||
|
||||
/* create new DCC struct */
|
||||
if ((new_dcc = (struct t_irc_dcc *)malloc (sizeof (struct t_irc_dcc))) == NULL)
|
||||
if ((new_dcc = malloc (sizeof (*new_dcc))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* default values */
|
||||
|
@ -979,8 +979,7 @@ irc_dcc_send_request (struct t_irc_server *server, int type, char *nick,
|
|||
free (dir1);
|
||||
return;
|
||||
}
|
||||
filename2 = (char *)malloc ((strlen (dir2) +
|
||||
strlen (filename) + 4) * sizeof (char));
|
||||
filename2 = malloc (strlen (dir2) + strlen (filename) + 4);
|
||||
if (!filename2)
|
||||
{
|
||||
gui_chat_printf_error (server->buffer,
|
||||
|
@ -1258,8 +1257,8 @@ irc_dcc_chat_recv (struct t_irc_dcc *dcc)
|
|||
ptr_buf = buffer;
|
||||
if (dcc->unterminated_message)
|
||||
{
|
||||
buf2 = (char *)malloc ((strlen (dcc->unterminated_message) +
|
||||
strlen (buffer) + 1) * sizeof (char));
|
||||
buf2 = malloc (strlen (dcc->unterminated_message) +
|
||||
strlen (buffer) + 1);
|
||||
if (buf2)
|
||||
{
|
||||
strcpy (buf2, dcc->unterminated_message);
|
||||
|
|
|
@ -224,8 +224,8 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
|
|||
{
|
||||
if (!strchr (server->nick_modes, mode))
|
||||
{
|
||||
server->nick_modes = (char *)realloc (server->nick_modes,
|
||||
(strlen (server->nick_modes) + 1 + 1) * sizeof (char));
|
||||
server->nick_modes = realloc (server->nick_modes,
|
||||
strlen (server->nick_modes) + 1 + 1);
|
||||
strcat (server->nick_modes, str_mode);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
|
@ -233,7 +233,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
|
|||
}
|
||||
else
|
||||
{
|
||||
server->nick_modes = (char *)malloc (2 * sizeof (char));
|
||||
server->nick_modes = malloc (2);
|
||||
strcpy (server->nick_modes, str_mode);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
|
@ -257,8 +257,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
|
|||
{
|
||||
new_size = strlen (server->nick_modes);
|
||||
memmove (pos, pos + 1, strlen (pos + 1) + 1);
|
||||
server->nick_modes = (char *)realloc (server->nick_modes,
|
||||
new_size * sizeof (char));
|
||||
server->nick_modes = realloc (server->nick_modes, new_size);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
|||
}
|
||||
|
||||
/* alloc memory for new nick */
|
||||
if ((new_nick = (struct t_irc_nick *)malloc (sizeof (struct t_irc_nick))) == NULL)
|
||||
if ((new_nick = malloc (sizeof (*new_nick))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* initialize new nick */
|
||||
|
|
|
@ -1162,7 +1162,7 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *command,
|
|||
{
|
||||
join_length = strlen (ptr_channel->name) + 1 +
|
||||
strlen (ptr_channel->key) + 1;
|
||||
join_string = (char *)malloc (join_length * sizeof (char));
|
||||
join_string = malloc (join_length);
|
||||
if (join_string)
|
||||
{
|
||||
snprintf (join_string, join_length, "%s %s",
|
||||
|
@ -3826,7 +3826,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *command,
|
|||
if (ptr_nick->host)
|
||||
free (ptr_nick->host);
|
||||
length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;
|
||||
ptr_nick->host = (char *)malloc (length * sizeof (char));
|
||||
ptr_nick->host = malloc (length);
|
||||
if (ptr_nick->host)
|
||||
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
|
||||
if (pos_attr)
|
||||
|
|
|
@ -239,7 +239,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
|
|||
server->autojoin = strdup (pos_channel);
|
||||
else
|
||||
{
|
||||
server->autojoin = (char *)malloc ((strlen (pos_channel) + 2) * sizeof (char));
|
||||
server->autojoin = malloc (strlen (pos_channel) + 2);
|
||||
strcpy (server->autojoin, "#");
|
||||
strcat (server->autojoin, pos_channel);
|
||||
}
|
||||
|
@ -253,10 +253,10 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
|
|||
// some default values
|
||||
if (server->port < 0)
|
||||
server->port = IRC_SERVER_DEFAULT_PORT;
|
||||
server->nick2 = (char *)malloc ((strlen (server->nick1) + 2) * sizeof (char));
|
||||
server->nick2 = malloc (strlen (server->nick1) + 2);
|
||||
strcpy (server->nick2, server->nick1);
|
||||
server->nick2 = strcat (server->nick2, "1");
|
||||
server->nick3 = (char *)malloc ((strlen (server->nick1) + 2) * sizeof (char));
|
||||
server->nick3 = malloc (strlen (server->nick1) + 2);
|
||||
strcpy (server->nick3, server->nick1);
|
||||
server->nick3 = strcat (server->nick3, "2");
|
||||
|
||||
|
@ -300,8 +300,7 @@ irc_server_set_addresses (struct t_irc_server *server, char *addresses)
|
|||
server->addresses_array = weechat_string_explode (server->addresses,
|
||||
",", 0, 0,
|
||||
&server->addresses_count);
|
||||
server->ports_array = (int *)malloc (server->addresses_count *
|
||||
sizeof (int *));
|
||||
server->ports_array = malloc (server->addresses_count * sizeof (server->ports_array[0]));
|
||||
for (i = 0; i < server->addresses_count; i++)
|
||||
{
|
||||
pos = strchr (server->addresses_array[i], '/');
|
||||
|
@ -572,7 +571,7 @@ irc_server_alloc ()
|
|||
struct t_irc_server *new_server;
|
||||
|
||||
/* alloc memory for new server */
|
||||
if ((new_server = (struct t_irc_server *)malloc (sizeof (struct t_irc_server))) == NULL)
|
||||
if ((new_server = malloc (sizeof (*new_server))) == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error when allocating new server"),
|
||||
|
@ -606,7 +605,7 @@ irc_server_outqueue_add (struct t_irc_server *server, char *msg1, char *msg2,
|
|||
{
|
||||
struct t_irc_outqueue *new_outqueue;
|
||||
|
||||
new_outqueue = (struct t_irc_outqueue *)malloc (sizeof (struct t_irc_outqueue));
|
||||
new_outqueue = malloc (sizeof (*new_outqueue));
|
||||
if (new_outqueue)
|
||||
{
|
||||
new_outqueue->message_before_mod = (msg1) ? strdup (msg1) : NULL;
|
||||
|
@ -1288,7 +1287,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
|
|||
if (!server->unterminated_message && !msg[0])
|
||||
return;
|
||||
|
||||
message = (struct t_irc_message *)malloc (sizeof (struct t_irc_message));
|
||||
message = malloc (sizeof (*message));
|
||||
if (!message)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
|
@ -1300,8 +1299,8 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
|
|||
message->server = server;
|
||||
if (server->unterminated_message)
|
||||
{
|
||||
message->data = (char *)malloc ((strlen (server->unterminated_message) +
|
||||
strlen (msg) + 1) * sizeof (char));
|
||||
message->data = malloc (strlen (server->unterminated_message) +
|
||||
strlen (msg) + 1);
|
||||
if (!message->data)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
|
@ -1346,9 +1345,9 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
|
|||
if (server->unterminated_message)
|
||||
{
|
||||
server->unterminated_message =
|
||||
(char *)realloc (server->unterminated_message,
|
||||
(strlen (server->unterminated_message) +
|
||||
strlen (string) + 1) * sizeof (char));
|
||||
realloc (server->unterminated_message,
|
||||
(strlen (server->unterminated_message) +
|
||||
strlen (string) + 1));
|
||||
if (!server->unterminated_message)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
|
@ -2210,7 +2209,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
|
|||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
addr_buffer = (unsigned char *)malloc (addr_buffer_len * sizeof(*addr_buffer));
|
||||
addr_buffer = malloc (addr_buffer_len * sizeof(*addr_buffer));
|
||||
if (!addr_buffer)
|
||||
return 1;
|
||||
addr_buffer[0] = 5; /* version 5 */
|
||||
|
|
|
@ -46,7 +46,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, char *log_filename)
|
|||
if (!buffer || !log_filename)
|
||||
return NULL;
|
||||
|
||||
new_logger_buffer = (struct t_logger_buffer *)malloc (sizeof (struct t_logger_buffer));
|
||||
new_logger_buffer = malloc (sizeof (*new_logger_buffer));
|
||||
if (new_logger_buffer)
|
||||
{
|
||||
new_logger_buffer->buffer = buffer;
|
||||
|
|
|
@ -122,7 +122,7 @@ logger_tail_file (char *filename, int n_lines)
|
|||
pos_eol[0] = '\0';
|
||||
pos_eol++;
|
||||
}
|
||||
new_line = (struct t_logger_line *)malloc (sizeof (struct t_logger_line));
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
{
|
||||
logger_tail_free (ptr_line);
|
||||
|
@ -131,8 +131,8 @@ logger_tail_file (char *filename, int n_lines)
|
|||
}
|
||||
if (part_of_line)
|
||||
{
|
||||
new_line->data = (char *)malloc ((strlen (pos_eol) +
|
||||
strlen (part_of_line) + 1) * sizeof (char));
|
||||
new_line->data = malloc ((strlen (pos_eol) +
|
||||
strlen (part_of_line) + 1));
|
||||
if (!new_line->data)
|
||||
{
|
||||
free (part_of_line);
|
||||
|
@ -161,8 +161,7 @@ logger_tail_file (char *filename, int n_lines)
|
|||
add string to part_of_line, we'll use that later */
|
||||
if (part_of_line)
|
||||
{
|
||||
new_part_of_line = (char *)malloc ((strlen (buf) +
|
||||
strlen (part_of_line) + 1) * sizeof (char));
|
||||
new_part_of_line = malloc (strlen (buf) + strlen (part_of_line) + 1);
|
||||
if (!new_part_of_line)
|
||||
{
|
||||
free (part_of_line);
|
||||
|
@ -177,7 +176,7 @@ logger_tail_file (char *filename, int n_lines)
|
|||
}
|
||||
else
|
||||
{
|
||||
part_of_line = (char *)malloc ((strlen (buf) + 1) * sizeof (char));
|
||||
part_of_line = malloc (strlen (buf) + 1);
|
||||
strcpy (part_of_line, buf);
|
||||
}
|
||||
ptr_buf = NULL;
|
||||
|
|
|
@ -227,7 +227,7 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
|||
if (name2)
|
||||
length += strlen (name2);
|
||||
length += 16;
|
||||
res = (char *)malloc (length * sizeof (char));
|
||||
res = malloc (length);
|
||||
if (res)
|
||||
{
|
||||
strcpy (res, log_path2);
|
||||
|
|
|
@ -99,8 +99,7 @@ plugin_api_mkdir_home (char *directory, int mode)
|
|||
|
||||
/* build directory, adding WeeChat home */
|
||||
dir_length = strlen (weechat_home) + strlen (directory) + 2;
|
||||
dir_name =
|
||||
(char *)malloc (dir_length * sizeof (char));
|
||||
dir_name = malloc (dir_length);
|
||||
if (!dir_name)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ plugin_config_search (char *plugin_name, char *option_name)
|
|||
char *internal_option;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
internal_option = (char *)malloc ((strlen (plugin_name) +
|
||||
strlen (option_name) + 2) * sizeof (char));
|
||||
internal_option = malloc (strlen (plugin_name) + strlen (option_name) + 2);
|
||||
if (!internal_option)
|
||||
return NULL;
|
||||
|
||||
|
@ -154,7 +153,7 @@ plugin_config_set_internal (char *option, char *value)
|
|||
{
|
||||
if (value && value[0])
|
||||
{
|
||||
ptr_option = (struct t_config_option *)malloc (sizeof (struct t_config_option));
|
||||
ptr_option = malloc (sizeof (*ptr_option));
|
||||
if (ptr_option)
|
||||
{
|
||||
/* create new option */
|
||||
|
@ -223,8 +222,7 @@ plugin_config_set (char *plugin_name, char *option_name, char *value)
|
|||
char *internal_option;
|
||||
int return_code;
|
||||
|
||||
internal_option = (char *)malloc ((strlen (plugin_name) +
|
||||
strlen (option_name) + 2) * sizeof (char));
|
||||
internal_option = malloc (strlen (plugin_name) + strlen (option_name) + 2);
|
||||
if (!internal_option)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ plugin_infolist_new ()
|
|||
{
|
||||
struct t_plugin_infolist *new_infolist;
|
||||
|
||||
new_infolist = (struct t_plugin_infolist *)malloc (sizeof (struct t_plugin_infolist));
|
||||
new_infolist = malloc (sizeof (*new_infolist));
|
||||
if (new_infolist)
|
||||
{
|
||||
new_infolist->items = NULL;
|
||||
|
@ -73,7 +73,7 @@ plugin_infolist_new_item (struct t_plugin_infolist *list)
|
|||
{
|
||||
struct t_plugin_infolist_item *new_item;
|
||||
|
||||
new_item = (struct t_plugin_infolist_item *)malloc (sizeof (struct t_plugin_infolist_item));
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
new_item->vars = NULL;
|
||||
|
@ -105,7 +105,7 @@ plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
|
|||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
|
@ -138,7 +138,7 @@ plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
|
|||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
|
@ -170,7 +170,7 @@ plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
|
|||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
|
@ -202,7 +202,7 @@ plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
|
|||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
|
@ -303,7 +303,7 @@ plugin_infolist_get_fields (struct t_plugin_infolist *list)
|
|||
length += strlen (ptr_var->name) + 3;
|
||||
}
|
||||
|
||||
list->ptr_item->fields = (char *)malloc ((length + 1) * sizeof (char));
|
||||
list->ptr_item->fields = malloc (length + 1);
|
||||
if (!list->ptr_item->fields)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ plugin_load (char *filename)
|
|||
}
|
||||
|
||||
/* create new plugin */
|
||||
new_plugin = (struct t_weechat_plugin *)malloc (sizeof (struct t_weechat_plugin));
|
||||
new_plugin = malloc (sizeof (*new_plugin));
|
||||
if (new_plugin)
|
||||
{
|
||||
/* variables */
|
||||
|
@ -513,7 +513,7 @@ plugin_auto_load ()
|
|||
}
|
||||
|
||||
/* auto-load plugins in WeeChat global lib dir */
|
||||
dir_name = (char *)malloc ((strlen (WEECHAT_LIBDIR) + 16) * sizeof (char));
|
||||
dir_name = malloc (strlen (WEECHAT_LIBDIR) + 16);
|
||||
if (dir_name)
|
||||
{
|
||||
snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16,
|
||||
|
|
|
@ -105,7 +105,7 @@ weechat_lua_exec (struct t_plugin_script *script,
|
|||
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = lua_tonumber (lua_current_interpreter, -1);
|
||||
ret_value = ret_i;
|
||||
|
|
|
@ -119,9 +119,9 @@ weechat_perl_exec (struct t_plugin_script *script,
|
|||
|
||||
#ifndef MULTIPLICITY
|
||||
length = strlen (script->interpreter) + strlen (function) + 3;
|
||||
func = (char *)malloc (length * sizeof (char));
|
||||
func = malloc (length);
|
||||
if (!func)
|
||||
return NULL;
|
||||
return NULL;
|
||||
snprintf (func, length, "%s::%s", (char *) script->interpreter, function);
|
||||
#else
|
||||
(void) length;
|
||||
|
@ -135,7 +135,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
|||
|
||||
/* are we loading the script file ? */
|
||||
if (strcmp (function, "weechat_perl_load_eval_file") != 0)
|
||||
perl_current_script = script;
|
||||
perl_current_script = script;
|
||||
|
||||
count = perl_call_argv (func, G_EVAL | G_SCALAR, argv);
|
||||
ret_value = NULL;
|
||||
|
@ -149,42 +149,42 @@ weechat_perl_exec (struct t_plugin_script *script,
|
|||
weechat_gettext ("%s%s: error: %s"),
|
||||
weechat_prefix ("error"), "perl", SvPV_nolen (ERRSV));
|
||||
(void) POPs; /* poping the 'undef' */
|
||||
mem_err = 0;
|
||||
mem_err = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != 1)
|
||||
{
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must "
|
||||
"return one valid value (%d)"),
|
||||
weechat_prefix ("error"), "perl", function, count);
|
||||
mem_err = 0;
|
||||
}
|
||||
mem_err = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
|
||||
{
|
||||
ret_s = newSVsv(POPs);
|
||||
ret_value = strdup (SvPV_nolen (ret_s));
|
||||
SvREFCNT_dec (ret_s);
|
||||
}
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
if (ret_i)
|
||||
*ret_i = POPi;
|
||||
ret_value = ret_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
{
|
||||
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
|
||||
{
|
||||
ret_s = newSVsv(POPs);
|
||||
ret_value = strdup (SvPV_nolen (ret_s));
|
||||
SvREFCNT_dec (ret_s);
|
||||
}
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = POPi;
|
||||
ret_value = ret_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" is "
|
||||
"internally misused"),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
mem_err = 0;
|
||||
}
|
||||
}
|
||||
mem_err = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PUTBACK;
|
||||
|
@ -197,11 +197,11 @@ weechat_perl_exec (struct t_plugin_script *script,
|
|||
|
||||
if (!ret_value && (mem_err == 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: not enough memory in function "
|
||||
"\"%s\""),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
|
|
|
@ -137,7 +137,7 @@ weechat_python_exec (struct t_plugin_script *script,
|
|||
else if (PyInt_Check (rc) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
|
||||
{
|
||||
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = (int) PyInt_AsLong(rc);
|
||||
ret_value = ret_i;
|
||||
|
@ -277,8 +277,8 @@ weechat_python_load (char *filename)
|
|||
"sub-interpreter"),
|
||||
weechat_prefix ("error"), "python");
|
||||
fclose (fp);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
return 0;
|
||||
/* PyEval_ReleaseLock (); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* PyThreadState_Swap (python_current_interpreter); */
|
||||
|
@ -293,10 +293,10 @@ weechat_python_load (char *filename)
|
|||
weechat_prefix ("error"), "python");
|
||||
fclose (fp);
|
||||
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* adding $weechat_dir/python in $PYTHONPATH */
|
||||
|
@ -304,19 +304,19 @@ weechat_python_load (char *filename)
|
|||
w_home = weechat_info_get ("weechat_dir");
|
||||
if (w_home)
|
||||
{
|
||||
len = strlen (w_home) + 1 + strlen("python") + 1;
|
||||
p_home = (char *)malloc (len * sizeof (char));
|
||||
if (p_home)
|
||||
{
|
||||
snprintf (p_home, len, "%s/python", w_home);
|
||||
path = PyString_FromString (p_home);
|
||||
if (path != NULL)
|
||||
{
|
||||
PyList_Insert (python_path, 0, path);
|
||||
Py_DECREF (path);
|
||||
}
|
||||
free (p_home);
|
||||
}
|
||||
len = strlen (w_home) + 1 + strlen("python") + 1;
|
||||
p_home = malloc (len);
|
||||
if (p_home)
|
||||
{
|
||||
snprintf (p_home, len, "%s/python", w_home);
|
||||
path = PyString_FromString (p_home);
|
||||
if (path != NULL)
|
||||
{
|
||||
PyList_Insert (python_path, 0, path);
|
||||
Py_DECREF (path);
|
||||
}
|
||||
free (p_home);
|
||||
}
|
||||
}
|
||||
|
||||
/* define some constants */
|
||||
|
@ -344,15 +344,15 @@ weechat_python_load (char *filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (PySys_SetObject("stdout", weechat_outputs) == -1)
|
||||
if (PySys_SetObject("stdout", weechat_outputs) == -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to redirect stdout"),
|
||||
weechat_prefix ("error"), "python");
|
||||
}
|
||||
if (PySys_SetObject("stderr", weechat_outputs) == -1)
|
||||
if (PySys_SetObject("stderr", weechat_outputs) == -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to redirect stderr"),
|
||||
weechat_prefix ("error"), "python");
|
||||
}
|
||||
|
@ -365,22 +365,22 @@ weechat_python_load (char *filename)
|
|||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to parse file \"%s\""),
|
||||
weechat_prefix ("error"), "python", filename);
|
||||
fclose (fp);
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
{
|
||||
script_remove (weechat_python_plugin, &python_scripts,
|
||||
python_current_script);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
script_remove (weechat_python_plugin, &python_scripts,
|
||||
python_current_script);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
|
||||
fclose (fp);
|
||||
|
||||
|
@ -391,11 +391,12 @@ weechat_python_load (char *filename)
|
|||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), "python", filename);
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
|
||||
|
|
|
@ -198,7 +198,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
|||
}
|
||||
else if ((TYPE(rc) == T_FIXNUM) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = NUM2INT(rc);
|
||||
ret_value = ret_i;
|
||||
|
|
|
@ -911,8 +911,8 @@ script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
|||
{
|
||||
char *option_fullname, *return_value;
|
||||
|
||||
option_fullname = (char *)malloc ((strlen (script->name) +
|
||||
strlen (option) + 2) * sizeof (char));
|
||||
option_fullname = malloc ((strlen (script->name) +
|
||||
strlen (option) + 2));
|
||||
if (!option_fullname)
|
||||
return NULL;
|
||||
|
||||
|
@ -939,8 +939,8 @@ script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
|||
char *option_fullname;
|
||||
int return_code;
|
||||
|
||||
option_fullname = (char *)malloc ((strlen (script->name) +
|
||||
strlen (option) + 2) * sizeof (char));
|
||||
option_fullname = malloc ((strlen (script->name) +
|
||||
strlen (option) + 2));
|
||||
if (!option_fullname)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ script_callback_alloc ()
|
|||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
|
||||
new_script_callback = (struct t_script_callback *)malloc (sizeof (struct t_script_callback));
|
||||
new_script_callback = malloc (sizeof (*new_script_callback));
|
||||
if (new_script_callback)
|
||||
{
|
||||
new_script_callback->script = NULL;
|
||||
|
|
|
@ -101,7 +101,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
|||
|
||||
/* add hook for config option */
|
||||
length = strlen (weechat_plugin->name) + 32;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s.%s",
|
||||
|
@ -114,7 +114,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
|||
/* create directories in WeeChat home */
|
||||
weechat_mkdir_home (weechat_plugin->name, 0755);
|
||||
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s/autoload", weechat_plugin->name);
|
||||
|
@ -124,7 +124,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
|||
|
||||
/* add command */
|
||||
length = strlen (completion) + strlen (weechat_plugin->name) + 16;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s|%%(%s_script)",
|
||||
|
@ -146,7 +146,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
|||
|
||||
/* add completion */
|
||||
length = strlen (weechat_plugin->name) + 16;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s_script", weechat_plugin->name);
|
||||
|
@ -214,7 +214,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
|||
if (!dir_home)
|
||||
return;
|
||||
dir_length = strlen (dir_home) + strlen (weechat_plugin->name) + 16;
|
||||
dir_name = (char *)malloc (dir_length * sizeof (char));
|
||||
dir_name = malloc (dir_length);
|
||||
if (!dir_name)
|
||||
return;
|
||||
|
||||
|
@ -264,7 +264,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
|||
if (!dir_home)
|
||||
return NULL;
|
||||
length = strlen (dir_home) + strlen (filename + 1) + 1;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length, "%s%s", dir_home, filename + 1);
|
||||
|
@ -279,7 +279,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
|||
/* try WeeChat user's autoload dir */
|
||||
length = strlen (dir_home) + strlen (weechat_plugin->name) + 8 +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
|
@ -293,7 +293,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
|||
/* try WeeChat language user's dir */
|
||||
length = strlen (dir_home) + strlen (weechat_plugin->name) +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
|
@ -305,7 +305,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
|||
|
||||
/* try WeeChat user's dir */
|
||||
length = strlen (dir_home) + strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
|
@ -322,7 +322,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
|||
{
|
||||
length = strlen (dir_system) + strlen (weechat_plugin->name) +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name,length,
|
||||
|
@ -369,7 +369,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
|||
license, name, weechat_plugin->license);
|
||||
}
|
||||
|
||||
new_script = (struct t_plugin_script *)malloc (sizeof (struct t_plugin_script));
|
||||
new_script = malloc (sizeof (*new_script));
|
||||
if (new_script)
|
||||
{
|
||||
new_script->filename = strdup (filename);
|
||||
|
|
|
@ -85,7 +85,7 @@ c_strndup (char *string, int length)
|
|||
if ((int)strlen (string) < length)
|
||||
return strdup (string);
|
||||
|
||||
result = (char *)malloc ((length + 1) * sizeof (char));
|
||||
result = malloc (length + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
@ -159,7 +159,7 @@ c_weechat_strreplace (char *string, char *search, char *replace)
|
|||
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
|
||||
|
||||
/* allocate new string */
|
||||
new_string = (char *)malloc (length_new * sizeof (char));
|
||||
new_string = malloc (length_new);
|
||||
if (!new_string)
|
||||
return strdup (string);
|
||||
|
||||
|
@ -215,9 +215,8 @@ c_explode_string (char *string, char *separators, int num_items_max,
|
|||
n_items = i;
|
||||
}
|
||||
|
||||
array =
|
||||
(char **)malloc ((num_items_max ? n_items : n_items + 1) *
|
||||
sizeof (char *));
|
||||
array = malloc ((num_items_max ? n_items : n_items + 1) *
|
||||
sizeof (array[0]));
|
||||
|
||||
ptr1 = string;
|
||||
ptr2 = string;
|
||||
|
@ -239,8 +238,7 @@ c_explode_string (char *string, char *separators, int num_items_max,
|
|||
{
|
||||
if (ptr2 - ptr1 > 0)
|
||||
{
|
||||
array[i] =
|
||||
(char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char));
|
||||
array[i] = malloc (ptr2 - ptr1 + 1);
|
||||
array[i] = strncpy (array[i], ptr1, ptr2 - ptr1);
|
||||
array[i][ptr2 - ptr1] = '\0';
|
||||
ptr1 = ++ptr2;
|
||||
|
@ -309,11 +307,11 @@ c_split_multi_command (char *command, char sep)
|
|||
ptr = ++p;
|
||||
}
|
||||
|
||||
array = (char **)malloc ((nb_substr + 1) * sizeof(char *));
|
||||
array = malloc ((nb_substr + 1) * sizeof(array[0]));
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
buffer = (char *)malloc ((strlen(command) + 1) * sizeof (char));
|
||||
buffer = malloc ((strlen(command) + 1));
|
||||
if (!buffer)
|
||||
{
|
||||
free (array);
|
||||
|
@ -363,7 +361,7 @@ c_split_multi_command (char *command, char sep)
|
|||
|
||||
free (buffer);
|
||||
|
||||
array = (char **)realloc (array, (arr_idx + 1) * sizeof(char *));
|
||||
array = realloc (array, (arr_idx + 1) * sizeof(array[0]));
|
||||
|
||||
return array;
|
||||
}
|
||||
|
@ -405,7 +403,7 @@ c_join_string(char **list, char *sep)
|
|||
len += strlen (list[i]);
|
||||
|
||||
len += i*strlen (sep) + 1;
|
||||
str = (char *)malloc (len * sizeof(char));
|
||||
str = malloc (len);
|
||||
if (str)
|
||||
{
|
||||
for (i = 0; list[i]; i++)
|
||||
|
|
|
@ -266,7 +266,7 @@ irc_msg *irc_parse_msg (char *msg)
|
|||
char *spc1, *spc2;
|
||||
irc_msg_type *it;
|
||||
|
||||
m = (irc_msg *) malloc(sizeof(irc_msg));
|
||||
m = malloc(sizeof(*m));
|
||||
|
||||
if (m)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ t_weechat_trigger *weechat_trigger_alloc (char *pattern, char *domain, char *com
|
|||
{
|
||||
t_weechat_trigger *new;
|
||||
|
||||
new = (t_weechat_trigger *)malloc (sizeof (t_weechat_trigger));
|
||||
new = malloc (sizeof (*new));
|
||||
if (new)
|
||||
{
|
||||
new->pattern = strdup (pattern);
|
||||
|
@ -733,7 +733,7 @@ weechat_trigger_edit (t_weechat_plugin *plugin, int todo)
|
|||
return -1;
|
||||
|
||||
len = strlen (weechat_dir) + strlen(DIR_SEP) + strlen(CONF_FILE) + 1;
|
||||
triggerrc = (char *)malloc (len * sizeof(char));
|
||||
triggerrc = malloc (len);
|
||||
if (!triggerrc)
|
||||
return -1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue