Rearrange the code.

Thanks again MonsterIestyn!
This commit is contained in:
Steel Titanium 2018-09-21 11:26:08 -04:00
parent af58ba9ae3
commit 68ec811909

View file

@ -2815,7 +2815,6 @@ UINT32 I_GetFreeMem(UINT32 *total)
long Buffers; long Buffers;
long Shmem; long Shmem;
long MemAvailable = -1; long MemAvailable = -1;
boolean guessed = false; // Stupid way to verify if the amount was guessed or not.
meminfo_fd = open(MEMINFO_FILE, O_RDONLY); meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
n = read(meminfo_fd, buf, 1023); n = read(meminfo_fd, buf, 1023);
@ -2848,19 +2847,14 @@ UINT32 I_GetFreeMem(UINT32 *total)
Buffers = get_entry(BUFFERS, buf); Buffers = get_entry(BUFFERS, buf);
Shmem = get_entry(SHMEM, buf); Shmem = get_entry(SHMEM, buf);
MemAvailable = Cached + MemFree + Buffers - Shmem; MemAvailable = Cached + MemFree + Buffers - Shmem;
guessed = true;
}
if (MemAvailable == -1 && guessed) if (MemAvailable == -1)
{ {
// Error // Error
if (total) if (total)
*total = 0L; *total = 0L;
return 0; return 0;
} }
if (guessed)
{
freeKBytes = MemAvailable; freeKBytes = MemAvailable;
} }
else else