summaryrefslogtreecommitdiff
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-04 07:49:25 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-04 07:49:25 +0000
commit91ff0e4cce94a53dd331b1510f18ca063aa2103e (patch)
treea2d89942fac322372df6a4989903ad43ec4a5222 /sys/kern/kern_malloc.c
parent29b7bb5e7b0fc48a72211cbce0bc358d1c8cf203 (diff)
Return a kmembuckets structure, rather than individual items, since they may be
out of sync between consecutive calls of sysctl(3).
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 73bf3d708b3..92c0f1a6ab5 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.21 2001/01/04 06:04:14 angelos Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.22 2001/01/04 07:49:24 angelos Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -494,9 +494,10 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen)
void *newp;
size_t newlen;
{
+ struct kmembuckets kb;
int i, siz;
- if (namelen != 3 && name[0] != KERN_MALLOC_BUCKETS)
+ if (namelen != 2 && name[0] != KERN_MALLOC_BUCKETS)
return (ENOTDIR); /* overloaded */
switch (name[0]) {
@@ -514,29 +515,10 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen)
return (sysctl_rdstring(oldp, oldlenp, newp, buckstring));
case KERN_MALLOC_BUCKET:
- switch (name[2]) {
- case KERN_MALLOC_CALLS:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_calls));
- case KERN_MALLOC_ALLOC:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_total));
- case KERN_MALLOC_FREE:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_totalfree));
- case KERN_MALLOC_ELEMENTS:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_elmpercl));
- case KERN_MALLOC_HIWAT:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_highwat));
- case KERN_MALLOC_COULDFREE:
- return (sysctl_rdquad(oldp, oldlenp, newp,
- bucket[BUCKETINDX(name[1])].kb_couldfree));
- default:
- return (EOPNOTSUPP);
- }
-
+ bcopy(&bucket[BUCKETINDX(name[1])], &kb, sizeof(kb));
+ kb.kb_next = kb.kb_last = 0;
+ return (sysctl_rdstruct(oldp, oldlenp, newp, &kb,
+ sizeof(kb)));
default:
return (EOPNOTSUPP);
}