Use HW_PHYSMEM instead of HW_USERMEM in get_total_system_memory_impl

The code checked for sysctl being available and HW_PHYSMEM being
defined, but HW_USERMEM was actually being used with sysctl instead
of HW_PHYSMEM.

The case for OpenBSD, etc. use HW_PHYSMEM64 (which is obviously a
64-bit variant of HW_PHYSMEM) and the case for OSX uses HW_MEMSIZE
(which appears to be a 64-bit variant of HW_PHYSMEM).

Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
This commit is contained in:
Kris Katterjohn 2019-01-03 17:19:46 -06:00 committed by Nick Mathewson
parent efe55b8898
commit 0f3d88a159

View File

@ -130,7 +130,7 @@ get_total_system_memory_impl(void)
* HW_PHYSMEM. */
size_t memsize=0;
size_t len = sizeof(memsize);
int mib[2] = {CTL_HW, HW_USERMEM};
int mib[2] = {CTL_HW, HW_PHYSMEM};
if (sysctl(mib,2,&memsize,&len,NULL,0))
return 0;