fix memfree command on 64bit
This commit is contained in:
1 parent
b6ef6eb801
commit
538de7d2d2
5 files changed
+14
-15
No files matched your search
@@ -24,7 +24,7 @@ static INT64 start_time; // as microseconds since the epoch
|
||||
|
||||
// I should probably return how much memory is remaining
|
||||
// for this process, considering Android's process memory limit.
|
||||
UINT32 I_GetFreeMem(UINT32 *total)
|
||||
size_t I_GetFreeMem(size_t *total)
|
||||
{
|
||||
// what the heck? sysinfo() is partially missing in bionic?
|
||||
/* struct sysinfo si; */
|
||||
|
||||
@@ -5,7 +5,7 @@ UINT8 graphics_started = 0;
|
||||
|
||||
UINT8 keyboard_started = 0;
|
||||
|
||||
UINT32 I_GetFreeMem(UINT32 *total)
|
||||
size_t I_GetFreeMem(size_t *total)
|
||||
{
|
||||
*total = 0;
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ extern UINT8 keyboard_started;
|
||||
|
||||
\return free memory in the system
|
||||
*/
|
||||
UINT32 I_GetFreeMem(UINT32 *total);
|
||||
size_t I_GetFreeMem(size_t *total);
|
||||
|
||||
/** \brief Returns precise time value for performance measurement. The precise
|
||||
time should be a monotonically increasing counter, and will wrap.
|
||||
|
||||
+6
-7
@@ -3806,8 +3806,7 @@ static long get_entry(const char* name, const char* buf)
|
||||
}
|
||||
#endif
|
||||
|
||||
// quick fix for compil
|
||||
UINT32 I_GetFreeMem(UINT32 *total)
|
||||
size_t I_GetFreeMem(size_t *total)
|
||||
{
|
||||
#ifdef FREEBSD
|
||||
struct vmmeter sum;
|
||||
@@ -3855,8 +3854,8 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||
info.dwLength = sizeof (MEMORYSTATUS);
|
||||
GlobalMemoryStatus( &info );
|
||||
if (total)
|
||||
*total = (UINT32)info.dwTotalPhys;
|
||||
return (UINT32)info.dwAvailPhys;
|
||||
*total = (size_t)info.dwTotalPhys;
|
||||
return (size_t)info.dwAvailPhys;
|
||||
#elif defined (__OS2__)
|
||||
UINT32 pr_arena;
|
||||
|
||||
@@ -3871,8 +3870,8 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||
/* Linux */
|
||||
char buf[1024];
|
||||
char *memTag;
|
||||
UINT32 freeKBytes;
|
||||
UINT32 totalKBytes;
|
||||
size_t freeKBytes;
|
||||
size_t totalKBytes;
|
||||
INT32 n;
|
||||
INT32 meminfo_fd = -1;
|
||||
long Cached;
|
||||
@@ -3903,7 +3902,7 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||
}
|
||||
|
||||
memTag += sizeof (MEMTOTAL);
|
||||
totalKBytes = atoi(memTag);
|
||||
totalKBytes = (size_t)atoi(memTag);
|
||||
|
||||
if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL)
|
||||
{
|
||||
|
||||
+5
-5
@@ -140,14 +140,14 @@ static void Command_Memdump_f(void);
|
||||
|
||||
void Z_Init(void)
|
||||
{
|
||||
UINT32 total, memfree;
|
||||
size_t total, memfree;
|
||||
|
||||
memset(&head, 0x00, sizeof(head));
|
||||
|
||||
head.next = head.prev = &head;
|
||||
|
||||
memfree = I_GetFreeMem(&total)>>20;
|
||||
CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree);
|
||||
CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(total>>20), sizeu2(memfree));
|
||||
|
||||
// Note: This allocates memory. Watch out.
|
||||
COM_AddCommand("memfree", Command_Memfree_f);
|
||||
@@ -616,7 +616,7 @@ size_t Z_TagUsage(INT32 tagnum)
|
||||
|
||||
void Command_Memfree_f(void)
|
||||
{
|
||||
UINT32 freebytes, totalbytes;
|
||||
size_t freebytes, totalbytes;
|
||||
|
||||
Z_CheckHeap(-1);
|
||||
CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
|
||||
@@ -644,8 +644,8 @@ void Command_Memfree_f(void)
|
||||
|
||||
CONS_Printf("\x82%s", M_GetText("System Memory Info\n"));
|
||||
freebytes = I_GetFreeMem(&totalbytes);
|
||||
CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10);
|
||||
CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10);
|
||||
CONS_Printf(M_GetText(" Total physical memory: %s KB\n"), sizeu1(totalbytes>>10));
|
||||
CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10));
|
||||
}
|
||||
|
||||
#ifdef ZDEBUG
|
||||
|
||||
Reference in new issue
Block a user