Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/pmap use ecalloc
details: https://anonhg.NetBSD.org/src/rev/986156b243fd
branches: trunk
changeset: 812414:986156b243fd
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 14 03:15:10 2015 +0000
description:
use ecalloc
diffstat:
usr.bin/pmap/Makefile | 6 +++---
usr.bin/pmap/main.c | 9 +++++----
usr.bin/pmap/pmap.c | 22 ++++++++++++----------
3 files changed, 20 insertions(+), 17 deletions(-)
diffs (117 lines):
diff -r 542a925e4375 -r 986156b243fd usr.bin/pmap/Makefile
--- a/usr.bin/pmap/Makefile Mon Dec 14 01:08:47 2015 +0000
+++ b/usr.bin/pmap/Makefile Mon Dec 14 03:15:10 2015 +0000
@@ -1,12 +1,12 @@
-# $NetBSD: Makefile,v 1.5 2011/05/26 12:56:33 joerg Exp $
+# $NetBSD: Makefile,v 1.6 2015/12/14 03:15:10 christos Exp $
USE_FORT?= yes # setgid
PROG= pmap
SRCS= main.c pmap.c
BINGRP= kmem
BINMODE= 2555
-LDADD= -lkvm
-DPADD= ${LIBKVM}
+LDADD= -lutil -lkvm
+DPADD= ${LIBUTIL} ${LIBKVM}
CWARNFLAGS.clang+= -Wno-format-extra-args
diff -r 542a925e4375 -r 986156b243fd usr.bin/pmap/main.c
--- a/usr.bin/pmap/main.c Mon Dec 14 01:08:47 2015 +0000
+++ b/usr.bin/pmap/main.c Mon Dec 14 03:15:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.25 2015/12/13 18:09:00 christos Exp $ */
+/* $NetBSD: main.c,v 1.26 2015/12/14 03:15:10 christos Exp $ */
/*
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.25 2015/12/13 18:09:00 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.26 2015/12/14 03:15:10 christos Exp $");
#endif
#include <sys/param.h>
@@ -48,6 +48,7 @@
#include <limits.h>
#include <string.h>
#include <signal.h>
+#include <util.h>
#include "pmap.h"
#include "main.h"
@@ -475,7 +476,7 @@
_KDEREF(kd, nchash_addr, &lnchash, sizeof(lnchash));
nchash = (size_t)lnchash + 1;
- nchashtbl = malloc(nchash * sizeof(*nchashtbl));
+ nchashtbl = ecalloc(nchash, sizeof(*nchashtbl));
_KDEREF(kd, nchashtbl_addr, nchashtbl, sizeof(*nchashtbl) * nchash);
ncpp = &_ncpp;
@@ -512,7 +513,7 @@
i, ncp->nc_vp, ncp->nc_dvp,
ncp->nc_nlen, ncp->nc_nlen, ncp->nc_name);
- ce = malloc(sizeof(struct cache_entry));
+ ce = emalloc(sizeof(struct cache_entry));
ce->ce_vp = ncp->nc_vp;
ce->ce_pvp = ncp->nc_dvp;
diff -r 542a925e4375 -r 986156b243fd usr.bin/pmap/pmap.c
--- a/usr.bin/pmap/pmap.c Mon Dec 14 01:08:47 2015 +0000
+++ b/usr.bin/pmap/pmap.c Mon Dec 14 03:15:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.51 2012/10/29 16:25:25 para Exp $ */
+/* $NetBSD: pmap.c,v 1.52 2015/12/14 03:15:10 christos Exp $ */
/*
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,10 +31,11 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pmap.c,v 1.51 2012/10/29 16:25:25 para Exp $");
+__RCSID("$NetBSD: pmap.c,v 1.52 2015/12/14 03:15:10 christos Exp $");
#endif
#include <string.h>
+#include <util.h>
#include "pmap.h"
#include "main.h"
@@ -565,22 +566,23 @@
* Assume that sizeof(struct vm_anon *) >= sizeof(size_t) and
* allocate that amount of space.
*/
- l = sizeof(struct vm_anon *) * D(amap, amap)->am_maxslot;
- am_anon = malloc(l);
+ am_anon = ecalloc(D(amap, amap)->am_maxslot, sizeof(*am_anon));
+ l = D(amap, amap)->am_maxslot * sizeof(*am_anon);
_KDEREF(kd, (u_long)D(amap, amap)->am_anon, am_anon, l);
- l = sizeof(int) * D(amap, amap)->am_maxslot;
- am_bckptr = malloc(l);
+ l = D(amap, amap)->am_maxslot * sizeof(*am_bckptr);
+ am_bckptr = ecalloc(D(amap, amap)->am_maxslot, sizeof(*am_bckptr));
_KDEREF(kd, (u_long)D(amap, amap)->am_bckptr, am_bckptr, l);
- l = sizeof(int) * D(amap, amap)->am_maxslot;
- am_slots = malloc(l);
+ l = D(amap, amap)->am_maxslot * sizeof(*am_slots);
+ am_slots = ecalloc(D(amap, amap)->am_maxslot, sizeof(*am_slots));
_KDEREF(kd, (u_long)D(amap, amap)->am_slots, am_slots, l);
if (D(amap, amap)->am_ppref != NULL &&
D(amap, amap)->am_ppref != PPREF_NONE) {
- l = sizeof(int) * D(amap, amap)->am_maxslot;
- am_ppref = malloc(l);
+ am_ppref = ecalloc(
+ D(amap, amap)->am_maxslot, sizeof(*am_ppref));
+ l = D(amap, amap)->am_maxslot * sizeof(*am_ppref);
_KDEREF(kd, (u_long)D(amap, amap)->am_ppref, am_ppref, l);
} else {
am_ppref = NULL;
Home |
Main Index |
Thread Index |
Old Index