aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/top/utils.c
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-06-02 21:40:45 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-06-02 21:40:45 +0000
commit4fedcd4983307c10aad92486f9f0abd7197c4f8f (patch)
tree0c1bb32846de8b22f2ad01700b783871b6bb775c /usr.bin/top/utils.c
parent5167f178ab866f4ccba4edac61260df4150f7560 (diff)
downloadsrc-4fedcd4983307c10aad92486f9f0abd7197c4f8f.tar.gz
src-4fedcd4983307c10aad92486f9f0abd7197c4f8f.zip
top(1): cleanup memory allocation and warnings
- Prefer calloc over malloc. This is more predicable and we're not in a performance sensitive context. [1] - Remove bogus comment (obsolete from prior commit). [2] - Remove void casts and type casts of NULL - Remove redundant declaration of 'quit' - Add additional const Reported by: kib [1], vangyzen [2]
Notes
Notes: svn path=/head/; revision=334540
Diffstat (limited to 'usr.bin/top/utils.c')
-rw-r--r--usr.bin/top/utils.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c
index f9cf340444e4..365ef9f99bc6 100644
--- a/usr.bin/top/utils.c
+++ b/usr.bin/top/utils.c
@@ -26,8 +26,6 @@
#include <paths.h>
#include <kvm.h>
-void quit(int);
-
int
atoiwi(const char *str)
{
@@ -201,10 +199,10 @@ argparse(char *line, int *cntp)
cnt += 3;
/* allocate a char * array to hold the pointers */
- argarray = malloc(cnt * sizeof(char *));
+ argarray = calloc(cnt, sizeof(char *));
/* allocate another array to hold the strings themselves */
- args = malloc(length+2);
+ args = calloc(length+2, 1);
/* initialization for main loop */
from = line;