Commit 6189c198 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Some applications call GlobalMemoryStatus() very often. Cache the

results of the call for 1 second (spotted by Corel).
parent 9b84bb66
......@@ -7,6 +7,7 @@
#include <sys/types.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
......@@ -1458,8 +1459,18 @@ DWORD WINAPI GlobalCompact( DWORD minfree )
VOID WINAPI GlobalMemoryStatus(
LPMEMORYSTATUS lpmem
) {
static MEMORYSTATUS cached_memstatus;
static int cache_lastchecked = 0;
FILE *f;
if (time(NULL)==cache_lastchecked) {
memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS));
return;
}
cache_lastchecked = time(NULL);
#ifdef linux
FILE *f = fopen( "/proc/meminfo", "r" );
f = fopen( "/proc/meminfo", "r" );
if (f)
{
char buffer[256];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment