mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-15 01:01:43 +00:00
Rearrange the code.
Thanks again MonsterIestyn!
This commit is contained in:
parent
af58ba9ae3
commit
68ec811909
1 changed files with 11 additions and 17 deletions
|
@ -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,26 +2847,21 @@ 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
|
||||||
{
|
{
|
||||||
memTag += sizeof (MEMAVAILABLE);
|
memTag += sizeof (MEMAVAILABLE);
|
||||||
freeKBytes = atoi(memTag);
|
freeKBytes = atoi(memTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total)
|
if (total)
|
||||||
*total = totalKBytes << 10;
|
*total = totalKBytes << 10;
|
||||||
|
|
Loading…
Reference in a new issue