1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 06:46:38 +02:00

Removed sizeof(char) and useless type casts from void* to another pointer type (patch from Leonid Evdokimov)

This commit is contained in:
Sebastien Helleu
2008-03-23 23:00:04 +01:00
parent 14feea7ab8
commit 57323fa71e
64 changed files with 273 additions and 285 deletions
+9 -11
View File
@@ -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++)
+1 -1
View File
@@ -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)
{
+2 -2
View File
@@ -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;