On Mon, Apr 15, 2019 at 9:24 PM Alexandre Julliard julliard@winehq.org wrote:
Vijay Kiran Kamuju infyquest@gmail.com writes:
+#ifdef HAVE_SYSINFO
struct sysinfo sinfo;if (!sysinfo(&sinfo)){ULONG64 freeram = (ULONG64)sinfo.freeram * sinfo.mem_unit;ULONG64 totalram = (ULONG64)sinfo.totalram * sinfo.mem_unit;ULONG64 totalswap = (ULONG64)sinfo.totalswap * sinfo.mem_unit;ULONG64 freeswap = (ULONG64)sinfo.freeswap * sinfo.mem_unit;if ((fp = fopen("/proc/meminfo", "r"))){unsigned long long available;char line[64];while (fgets(line, sizeof(line), fp)){if (sscanf(line, "MemAvailable: %llu kB", &available) == 1){freeram = min(available * 1024, totalram);break;}}fclose(fp);}It seems to me that as long as we are parsing /proc/meminfo, we could get everything from there, instead of mixing it up with sysinfo().
-- Alexandre Julliard julliard@winehq.org
I believe the original author's intent was to make it work also in the *bsd systems where '/proc/meminfo' is not available and sysinfo syscall is available. I can rewrite this patch by parsing the /proc/meminfo, that might make this smaller and not dependent on sysinfo but working only in linux.
--- Vijay