summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-04-10 08:48:35 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-04-10 08:48:35 +0000
commit6fe8f82982b08693b335dbdf387410f1ceec3521 (patch)
tree04c496a2b5e9b4d53b901047a41135f802eb6a97 /sys/kern
parentddccf95d0565bc56e5398f9e48c5e192eaf1aab8 (diff)
woah. last commit contained way too much. revert, and apply only the change intended.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_malloc.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index a891cbbd976..f72652b8f24 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.49 2003/04/10 02:04:24 tedu Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.50 2003/04/10 08:48:34 tedu Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -524,7 +524,6 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p)
struct proc *p;
{
struct kmembuckets kb;
- char *strp, *endp;
int i, siz;
if (namelen != 2 && name[0] != KERN_MALLOC_BUCKETS &&
@@ -537,19 +536,12 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p)
if (buckstring_init == 0) {
buckstring_init = 1;
bzero(buckstring, sizeof(buckstring));
- strp = buckstring;
- endp = strp + sizeof(buckstring) - 1;
- siz = 0;
- for (i = MINBUCKET; i < MINBUCKET + 16; i++) {
- siz = snprintf(strp, (endp - strp), "%d,",
- (u_int)(1<<i));
- if (strp + siz >= endp)
- break;
- strp += siz;
- }
+ for (siz = 0, i = MINBUCKET; i < MINBUCKET + 16; i++)
+ siz += sprintf(buckstring + siz,
+ "%d,", (u_int)(1<<i));
/* Remove trailing comma */
if (siz)
- *(strp - 1) = '\0';
+ buckstring[siz - 1] = '\0';
}
return (sysctl_rdstring(oldp, oldlenp, newp, buckstring));
@@ -583,20 +575,13 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p)
}
memall = malloc(totlen + M_LAST, M_SYSCTL, M_WAITOK);
bzero(memall, totlen + M_LAST);
- strp = memall;
- endp = memall + totlen + M_LAST;
- siz = 0;
- for (i = 0; i < M_LAST; i++) {
- siz = snprintf(strp, (endp - strp), "%s,",
+ for (siz = 0, i = 0; i < M_LAST; i++)
+ siz += sprintf(memall + siz, "%s,",
memname[i] ? memname[i] : "");
- if (strp + siz >= endp)
- break;
- strp += siz;
- }
/* Remove trailing comma */
if (siz)
- *(strp - 1) = '\0';
+ memall[siz - 1] = '\0';
/* Now, convert all spaces to underscores */
for (i = 0; i < totlen; i++)