1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 09:43:13 +02:00

Use of sizeof(char) in all malloc/realloc for strings

This commit is contained in:
Sebastien Helleu
2008-02-02 21:12:16 +01:00
parent d7cc27f713
commit 28e811c09c
38 changed files with 99 additions and 239 deletions
+1 -1
View File
@@ -104,7 +104,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 = (int *)malloc (sizeof (int));
if (ret_i)
*ret_i = lua_tonumber (lua_current_interpreter, -1);
ret_value = ret_i;
+2 -2
View File
@@ -118,7 +118,7 @@ weechat_perl_exec (struct t_plugin_script *script,
#ifndef MULTIPLICITY
int length = strlen (script->interpreter) + strlen (function) + 3;
func = (char *)malloc (length * sizeof(char));
func = (char *)malloc (length * sizeof (char));
if (!func)
return NULL;
snprintf (func, length, "%s::%s", (char *) script->interpreter, function);
@@ -170,7 +170,7 @@ weechat_perl_exec (struct t_plugin_script *script,
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
ret_i = (int *)malloc (sizeof(int));
ret_i = (int *)malloc (sizeof (int));
if (ret_i)
*ret_i = POPi;
ret_value = ret_i;
+2 -2
View File
@@ -129,7 +129,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 = (int *)malloc (sizeof (int));
if (ret_i)
*ret_i = (int) PyInt_AsLong(rc);
ret_value = ret_i;
@@ -297,7 +297,7 @@ weechat_python_load (char *filename)
if (w_home)
{
len = strlen (w_home) + 1 + strlen("python") + 1;
p_home = (char *)malloc (len * sizeof(char));
p_home = (char *)malloc (len * sizeof (char));
if (p_home)
{
snprintf (p_home, len, "%s/python", w_home);
+1 -1
View File
@@ -185,7 +185,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 = (int *)malloc (sizeof (int));
if (ret_i)
*ret_i = NUM2INT(rc);
ret_value = ret_i;
+4 -4
View File
@@ -844,8 +844,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);
option_fullname = (char *)malloc ((strlen (script->name) +
strlen (option) + 2) * sizeof (char));
if (!option_fullname)
return NULL;
@@ -872,8 +872,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);
option_fullname = (char *)malloc ((strlen (script->name) +
strlen (option) + 2) * sizeof (char));
if (!option_fullname)
return 0;
+9 -9
View File
@@ -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);
string = (char *)malloc (length * sizeof (char));
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, 0644);
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
string = (char *)malloc (length);
string = (char *)malloc (length * sizeof (char));
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);
string = (char *)malloc (length * sizeof (char));
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);
string = (char *)malloc (length * sizeof (char));
if (string)
{
snprintf (string, length, "%s_script", weechat_plugin->name);
@@ -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);
final_name = (char *)malloc (length * sizeof (char));
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);
final_name = (char *)malloc (length * sizeof (char));
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);
final_name = (char *)malloc (length * sizeof (char));
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);
final_name = (char *)malloc (length * sizeof (char));
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);
final_name = (char *)malloc (length * sizeof (char));
if (final_name)
{
snprintf (final_name,length,