summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorotto <>2018-11-06 08:01:43 +0000
committerotto <>2018-11-06 08:01:43 +0000
commit02992c23d43d749a426482628905fae80714aa85 (patch)
treeac9c06bb3d5ceb4239c251088e7fb76d6bd5d9aa
parent63569101089cbba78ffa6d2b7ab83e719262f5f0 (diff)
downloadopenbsd-02992c23d43d749a426482628905fae80714aa85.tar.gz
openbsd-02992c23d43d749a426482628905fae80714aa85.tar.bz2
openbsd-02992c23d43d749a426482628905fae80714aa85.zip
Use the new vm.malloc_conf sysctl; ok millert@ deraadt@
-rw-r--r--src/lib/libc/stdlib/malloc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index 70e7f37dc8..af9cf39199 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.250 2018/11/05 08:23:40 otto Exp $ */ 1/* $OpenBSD: malloc.c,v 1.251 2018/11/06 08:01:43 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -28,6 +28,8 @@
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/queue.h> 29#include <sys/queue.h>
30#include <sys/mman.h> 30#include <sys/mman.h>
31#include <sys/sysctl.h>
32#include <uvm/uvmexp.h>
31#include <errno.h> 33#include <errno.h>
32#include <stdarg.h> 34#include <stdarg.h>
33#include <stdint.h> 35#include <stdint.h>
@@ -386,8 +388,9 @@ omalloc_parseopt(char opt)
386static void 388static void
387omalloc_init(void) 389omalloc_init(void)
388{ 390{
389 char *p, *q, b[64]; 391 char *p, *q, b[16];
390 int i, j; 392 int i, j, mib[2];
393 size_t sb;
391 394
392 /* 395 /*
393 * Default options 396 * Default options
@@ -398,10 +401,12 @@ omalloc_init(void)
398 for (i = 0; i < 3; i++) { 401 for (i = 0; i < 3; i++) {
399 switch (i) { 402 switch (i) {
400 case 0: 403 case 0:
401 j = readlink("/etc/malloc.conf", b, sizeof b - 1); 404 mib[0] = CTL_VM;
402 if (j <= 0) 405 mib[1] = VM_MALLOC_CONF;
406 sb = sizeof(b);
407 j = sysctl(mib, 2, b, &sb, NULL, 0);
408 if (j != 0)
403 continue; 409 continue;
404 b[j] = '\0';
405 p = b; 410 p = b;
406 break; 411 break;
407 case 1: 412 case 1: