diff options
author | delphij <delphij@FreeBSD.org> | 2008-10-17 20:11:28 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2008-10-17 20:11:28 +0000 |
commit | d3b188efba3a977ca714ec1cdb658d410f0e491b (patch) | |
tree | 2854074e6728215d366f93cabac27963c947885d /lib | |
parent | 0c0113fdeff5e63fa9e8a2a9831d36c970921ea8 (diff) | |
download | FreeBSD-src-d3b188efba3a977ca714ec1cdb658d410f0e491b.zip FreeBSD-src-d3b188efba3a977ca714ec1cdb658d410f0e491b.tar.gz |
Reduce code duplication: use calloc() intead of malloc()
and memset afterward.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libkvm/kvm.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index e9d5a78..8ff8a2b 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -244,11 +244,10 @@ kvm_openfiles(uf, mf, sf, flag, errout) { kvm_t *kd; - if ((kd = malloc(sizeof(*kd))) == NULL) { + if ((kd = calloc(1, sizeof(*kd))) == NULL) { (void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX); return (0); } - memset(kd, 0, sizeof(*kd)); kd->program = 0; return (_kvm_open(kd, uf, mf, flag, errout)); } @@ -263,13 +262,12 @@ kvm_open(uf, mf, sf, flag, errstr) { kvm_t *kd; - if ((kd = malloc(sizeof(*kd))) == NULL) { + if ((kd = calloc(1, sizeof(*kd))) == NULL) { if (errstr != NULL) (void)fprintf(stderr, "%s: %s\n", errstr, strerror(errno)); return (0); } - memset(kd, 0, sizeof(*kd)); kd->program = errstr; return (_kvm_open(kd, uf, mf, flag, NULL)); } |