Module Name:    src
Committed By:   martin
Date:           Tue Jul 20 16:40:12 UTC 2021

Modified Files:
        src/usr.sbin/sysinst: util.c

Log Message:
RAM size will not change during installation, do the sysctl() dance
only once.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/sysinst/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/util.c
diff -u src/usr.sbin/sysinst/util.c:1.57 src/usr.sbin/sysinst/util.c:1.58
--- src/usr.sbin/sysinst/util.c:1.57	Sun Jan 31 22:45:47 2021
+++ src/usr.sbin/sysinst/util.c	Tue Jul 20 16:40:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.57 2021/01/31 22:45:47 rillig Exp $	*/
+/*	$NetBSD: util.c,v 1.58 2021/07/20 16:40:12 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -264,11 +264,14 @@ file_mode_match(const char *path, unsign
 uint64_t
 get_ramsize(void)
 {
-	uint64_t ramsize;
-	size_t len = sizeof ramsize;
-	int mib[2] = {CTL_HW, HW_PHYSMEM64};
+	static uint64_t ramsize;
 
-	sysctl(mib, 2, &ramsize, &len, NULL, 0);
+	if (ramsize == 0) {
+		size_t len = sizeof ramsize;
+		int mib[2] = {CTL_HW, HW_PHYSMEM64};
+
+		sysctl(mib, 2, &ramsize, &len, NULL, 0);
+	}
 
 	/* Find out how many Megs ... round up. */
 	return (ramsize + MEG - 1) / MEG;

Reply via email to