home
/
code
/
khatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4d66492
)
Switch from malloc to calloc
author
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 5 Mar 2020 17:06:59 +0000
(12:06 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 5 Mar 2020 17:06:59 +0000
(12:06 -0500)
x5/khatus.c
patch
|
blob
|
blame
|
history
diff --git
a/x5/khatus.c
b/x5/khatus.c
index
c7660b4
..
34ac42f
100644
(file)
--- a/
x5/khatus.c
+++ b/
x5/khatus.c
@@
-111,7
+111,7
@@
void
parse_opts_opt_s(Config *cfg, int argc, char *argv[], int i)
{
if (i < argc) {
parse_opts_opt_s(Config *cfg, int argc, char *argv[], int i)
{
if (i < argc) {
- cfg->separator =
malloc((strlen(argv[i]) + 1) *
sizeof(char));
+ cfg->separator =
calloc((strlen(argv[i]) + 1),
sizeof(char));
strcpy(cfg->separator, argv[i]);
opts_parse_any(cfg, argc, argv, ++i);
} else {
strcpy(cfg->separator, argv[i]);
opts_parse_any(cfg, argc, argv, ++i);
} else {
@@
-123,7
+123,7
@@
void
parse_opts_opt_t(Config *cfg, int argc, char *argv[], int i)
{
if (i < argc) {
parse_opts_opt_t(Config *cfg, int argc, char *argv[], int i)
{
if (i < argc) {
- cfg->timefmt =
malloc((strlen(argv[i]) + 1) *
sizeof(char));
+ cfg->timefmt =
calloc((strlen(argv[i]) + 1),
sizeof(char));
strcpy(cfg->timefmt, argv[i]);
opts_parse_any(cfg, argc, argv, ++i);
} else {
strcpy(cfg->timefmt, argv[i]);
opts_parse_any(cfg, argc, argv, ++i);
} else {
@@
-156,7
+156,7
@@
parse_opts_spec(Config *cfg, int argc, char *argv[], int i)
usage("[spec] Invalid width: \"%s\", for file \"%s\"\n", w, n);
if (!is_pos_num(t))
usage("[spec] Invalid TTL: \"%s\", for file \"%s\"\n", t, n);
usage("[spec] Invalid width: \"%s\", for file \"%s\"\n", w, n);
if (!is_pos_num(t))
usage("[spec] Invalid TTL: \"%s\", for file \"%s\"\n", t, n);
- File *f =
malloc(
sizeof(struct File));
+ File *f =
calloc(1,
sizeof(struct File));
if (f) {
f->name = n;
f->fd = -1;
if (f) {
f->name = n;
f->fd = -1;
@@
-270,7
+270,7
@@
main(int argc, char *argv[])
nfiles++;
}
width += (seplen * (nfiles - 1));
nfiles++;
}
width += (seplen * (nfiles - 1));
- buf =
malloc(
width + 1);
+ buf =
calloc(1,
width + 1);
if (buf == NULL)
fatal("[memory] Failed to allocate buffer of %d bytes", width);
memset(buf, ' ', width);
if (buf == NULL)
fatal("[memory] Failed to allocate buffer of %d bytes", width);
memset(buf, ' ', width);
This page took
0.023623 seconds
and
4
git commands to generate.