Commit bca90bac bca90bac24a8bb2bad44fe3f3db328af1beb0a08 by Sergey Poznyakoff

use util_[cm]alloc() where appropriate

1 parent 5a5f7a59
......@@ -99,7 +99,7 @@ alias_rehash()
return 1;
}
aliases = calloc(hash_size[hash_num], sizeof (aliases[0]));
aliases = util_calloc(hash_size[hash_num], sizeof (aliases[0]));
if (old_aliases)
{
for (i = 0; i < hash_size[hash_num-1]; i++)
......
......@@ -72,12 +72,7 @@ mail_set_my_name (char *name)
my_name = strdup (name);
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname)-1] = 0;
my_email = malloc (strlen (name) + strlen (hostname) + 2);
if (!my_email)
{
util_error("not enough memory");
abort ();
}
my_email = util_malloc (strlen (name) + strlen (hostname) + 2);
sprintf (my_email, "%s@%s", name, hostname);
}
......
......@@ -73,7 +73,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
int len;
char *home = getenv("HOME");
len = strlen (home) + strlen ("/mbox") + 1;
args->file = malloc(len * sizeof (char));
args->file = util_malloc(len * sizeof (char));
strcpy (args->file, home);
strcat (args->file, "/mbox");
}
......@@ -391,7 +391,7 @@ mail_mainloop(char *(*input) __P((void *, int)), void *closure, int do_history)
break;
}
command[len-1] = '\0';
buf = malloc ((len + strlen (command2)) * sizeof (char));
buf = util_malloc ((len + strlen (command2)) * sizeof (char));
strcpy (buf, command);
strcat (buf, command2);
free (command);
......
......@@ -48,7 +48,7 @@ mail_shell (int argc, char **argv)
char *buf = NULL;
/* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */
argvec = malloc (4 * (sizeof (char *)));
argvec = util_malloc (4 * (sizeof (char *)));
argcv_string (argc-1, &argv[1], &buf);
......
......@@ -31,7 +31,7 @@ mail_unset (int argc, char **argv)
int status = 0, i = 1;
for (i=1; i < argc; i++)
{
char *buf = malloc ((7+strlen (argv[i])) * sizeof (char));
char *buf = util_malloc ((7+strlen (argv[i])) * sizeof (char));
strcpy (buf, "set no");
strcat (buf, argv[i]);
if (!util_do_command (buf))
......