use util_[cm]alloc() where appropriate
Showing
5 changed files
with
6 additions
and
11 deletions
... | @@ -99,7 +99,7 @@ alias_rehash() | ... | @@ -99,7 +99,7 @@ alias_rehash() |
99 | return 1; | 99 | return 1; |
100 | } | 100 | } |
101 | 101 | ||
102 | aliases = calloc(hash_size[hash_num], sizeof (aliases[0])); | 102 | aliases = util_calloc(hash_size[hash_num], sizeof (aliases[0])); |
103 | if (old_aliases) | 103 | if (old_aliases) |
104 | { | 104 | { |
105 | for (i = 0; i < hash_size[hash_num-1]; i++) | 105 | for (i = 0; i < hash_size[hash_num-1]; i++) | ... | ... |
... | @@ -72,12 +72,7 @@ mail_set_my_name (char *name) | ... | @@ -72,12 +72,7 @@ mail_set_my_name (char *name) |
72 | my_name = strdup (name); | 72 | my_name = strdup (name); |
73 | gethostname(hostname, sizeof(hostname)); | 73 | gethostname(hostname, sizeof(hostname)); |
74 | hostname[sizeof(hostname)-1] = 0; | 74 | hostname[sizeof(hostname)-1] = 0; |
75 | my_email = malloc (strlen (name) + strlen (hostname) + 2); | 75 | my_email = util_malloc (strlen (name) + strlen (hostname) + 2); |
76 | if (!my_email) | ||
77 | { | ||
78 | util_error("not enough memory"); | ||
79 | abort (); | ||
80 | } | ||
81 | sprintf (my_email, "%s@%s", name, hostname); | 76 | sprintf (my_email, "%s@%s", name, hostname); |
82 | } | 77 | } |
83 | 78 | ... | ... |
... | @@ -73,7 +73,7 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -73,7 +73,7 @@ parse_opt (int key, char *arg, struct argp_state *state) |
73 | int len; | 73 | int len; |
74 | char *home = getenv("HOME"); | 74 | char *home = getenv("HOME"); |
75 | len = strlen (home) + strlen ("/mbox") + 1; | 75 | len = strlen (home) + strlen ("/mbox") + 1; |
76 | args->file = malloc(len * sizeof (char)); | 76 | args->file = util_malloc(len * sizeof (char)); |
77 | strcpy (args->file, home); | 77 | strcpy (args->file, home); |
78 | strcat (args->file, "/mbox"); | 78 | strcat (args->file, "/mbox"); |
79 | } | 79 | } |
... | @@ -391,7 +391,7 @@ mail_mainloop(char *(*input) __P((void *, int)), void *closure, int do_history) | ... | @@ -391,7 +391,7 @@ mail_mainloop(char *(*input) __P((void *, int)), void *closure, int do_history) |
391 | break; | 391 | break; |
392 | } | 392 | } |
393 | command[len-1] = '\0'; | 393 | command[len-1] = '\0'; |
394 | buf = malloc ((len + strlen (command2)) * sizeof (char)); | 394 | buf = util_malloc ((len + strlen (command2)) * sizeof (char)); |
395 | strcpy (buf, command); | 395 | strcpy (buf, command); |
396 | strcat (buf, command2); | 396 | strcat (buf, command2); |
397 | free (command); | 397 | free (command); | ... | ... |
... | @@ -48,7 +48,7 @@ mail_shell (int argc, char **argv) | ... | @@ -48,7 +48,7 @@ mail_shell (int argc, char **argv) |
48 | char *buf = NULL; | 48 | char *buf = NULL; |
49 | 49 | ||
50 | /* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */ | 50 | /* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */ |
51 | argvec = malloc (4 * (sizeof (char *))); | 51 | argvec = util_malloc (4 * (sizeof (char *))); |
52 | 52 | ||
53 | argcv_string (argc-1, &argv[1], &buf); | 53 | argcv_string (argc-1, &argv[1], &buf); |
54 | 54 | ... | ... |
... | @@ -31,7 +31,7 @@ mail_unset (int argc, char **argv) | ... | @@ -31,7 +31,7 @@ mail_unset (int argc, char **argv) |
31 | int status = 0, i = 1; | 31 | int status = 0, i = 1; |
32 | for (i=1; i < argc; i++) | 32 | for (i=1; i < argc; i++) |
33 | { | 33 | { |
34 | char *buf = malloc ((7+strlen (argv[i])) * sizeof (char)); | 34 | char *buf = util_malloc ((7+strlen (argv[i])) * sizeof (char)); |
35 | strcpy (buf, "set no"); | 35 | strcpy (buf, "set no"); |
36 | strcat (buf, argv[i]); | 36 | strcat (buf, argv[i]); |
37 | if (!util_do_command (buf)) | 37 | if (!util_do_command (buf)) | ... | ... |
-
Please register or sign in to post a comment