1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 16:53:14 +02:00

core: replace calls to malloc by calloc

After these calls to malloc the memory is set to zero, so it's better to call
calloc that does it already.
This commit is contained in:
Sébastien Helleu
2020-08-17 19:57:10 +02:00
parent fca5a4b42c
commit fbc2438c1c
2 changed files with 5 additions and 17 deletions
+4 -12
View File
@@ -614,8 +614,6 @@ gui_color_build (int number, int foreground, int background)
void
gui_color_init_vars ()
{
int size;
gui_color_term_has_colors = (has_colors ()) ? 1 : 0;
gui_color_term_colors = 0;
gui_color_term_color_pairs = 0;
@@ -637,12 +635,9 @@ gui_color_init_vars ()
/* TODO: ncurses may support 65536, but short type used for pairs supports only 32768? */
gui_color_num_pairs = (gui_color_term_color_pairs >= 32768) ?
32767 : gui_color_term_color_pairs - 1;
size = (gui_color_term_colors + 2)
* (gui_color_term_colors + 2)
* sizeof (gui_color_pairs[0]);
gui_color_pairs = malloc (size);
if (gui_color_pairs)
memset (gui_color_pairs, 0, size);
gui_color_pairs = calloc (
(gui_color_term_colors + 2) * (gui_color_term_colors + 2),
sizeof (gui_color_pairs[0]));
gui_color_pairs_used = 0;
/* reserved for future usage */
@@ -667,10 +662,7 @@ gui_color_init_vars ()
gui_color_term_color_pairs = 1;
gui_color_term_can_change_color = 0;
gui_color_num_pairs = 1;
size = sizeof (gui_color_pairs[0]);
gui_color_pairs = malloc (size);
if (gui_color_pairs)
memset (gui_color_pairs, 0, size);
gui_color_pairs = calloc (1, sizeof (gui_color_pairs[0]));
gui_color_pairs_used = 0;
}
}
+1 -5
View File
@@ -1440,11 +1440,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
buffer_without_name_displayed = NULL;
if (CONFIG_BOOLEAN(config_look_hotlist_unique_numbers) && last_gui_buffer)
{
buffer_without_name_displayed = malloc (last_gui_buffer->number);
if (buffer_without_name_displayed)
memset (buffer_without_name_displayed, 0, last_gui_buffer->number);
}
buffer_without_name_displayed = calloc (last_gui_buffer->number, 1);
numbers_count = 0;
names_count = 0;