diff options
-rw-r--r-- | usr.bin/top/display.c | 10 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 12 | ||||
-rw-r--r-- | usr.bin/top/utils.c | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 8d0c09d746e..b0d94ead223 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.25 2007/05/29 00:56:56 otto Exp $ */ +/* $OpenBSD: display.c,v 1.26 2007/07/27 13:57:50 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -183,22 +183,22 @@ display_init(struct statics * statics) /* save pointers and allocate space for names */ procstate_names = statics->procstate_names; num_procstates = string_count(procstate_names); - lprocstates = malloc(num_procstates * sizeof(int)); + lprocstates = calloc(num_procstates, sizeof(int)); if (lprocstates == NULL) err(1, NULL); cpustate_names = statics->cpustate_names; num_cpustates = string_count(cpustate_names); - lcpustates = malloc(ncpu * sizeof(int64_t *)); + lcpustates = calloc(ncpu, sizeof(int64_t *)); if (lcpustates == NULL) err(1, NULL); for (cpu = 0; cpu < ncpu; cpu++) { - lcpustates[cpu] = malloc(num_cpustates * sizeof(int64_t)); + lcpustates[cpu] = calloc(num_cpustates, sizeof(int64_t)); if (lcpustates[cpu] == NULL) err(1, NULL); } - cpustate_columns = malloc(num_cpustates * sizeof(int)); + cpustate_columns = calloc(num_cpustates, sizeof(int)); if (cpustate_columns == NULL) err(1, NULL); diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 58059465974..3eaa05dcb00 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.61 2007/05/29 00:56:56 otto Exp $ */ +/* $OpenBSD: machine.c,v 1.62 2007/07/27 13:57:50 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -162,12 +162,12 @@ machine_init(struct statics *statics) mib[1] = HW_NCPU; if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) return (-1); - cpu_states = malloc(ncpu * CPUSTATES * sizeof(int64_t)); + cpu_states = calloc(ncpu, CPUSTATES * sizeof(int64_t)); if (cpu_states == NULL) err(1, NULL); - cp_time = malloc(ncpu * sizeof(int64_t *)); - cp_old = malloc(ncpu * sizeof(int64_t *)); - cp_diff = malloc(ncpu * sizeof(int64_t *)); + cp_time = calloc(ncpu, sizeof(int64_t *)); + cp_old = calloc(ncpu, sizeof(int64_t *)); + cp_diff = calloc(ncpu, sizeof(int64_t *)); if (cp_time == NULL || cp_old == NULL || cp_diff == NULL) err(1, NULL); for (cpu = 0; cpu < ncpu; cpu++) { @@ -709,7 +709,7 @@ swapmode(int *used, int *total) if (nswap == 0) return 0; - swdev = malloc(nswap * sizeof(*swdev)); + swdev = calloc(nswap, sizeof(*swdev)); if (swdev == NULL) return 0; diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c index 317124c5700..4524d7b1f92 100644 --- a/usr.bin/top/utils.c +++ b/usr.bin/top/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.19 2007/07/16 15:14:33 otto Exp $ */ +/* $OpenBSD: utils.c,v 1.20 2007/07/27 13:57:50 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -167,7 +167,7 @@ argparse(char *line, int *cntp) cnt += 3; /* allocate a char * array to hold the pointers */ - if ((argarray = malloc(cnt * sizeof(char *))) == NULL) + if ((argarray = calloc(cnt, sizeof(char *))) == NULL) err(1, NULL); /* allocate another array to hold the strings themselves */ |