Example #1
0
char *sysinfo_backend_get_memory(void)
{
    unsigned long long mem_total;
    unsigned long long mem_free;
    unsigned long long swap_total;
    unsigned long long swap_free;
    char *swap_fmt = NULL, *mem_fmt, *ret;

    if (xs_parse_meminfo (&mem_total, &mem_free, 0) == 1)
    {
        return NULL;
    }
    if (xs_parse_meminfo (&swap_total, &swap_free, 1) != 1)
    {
        swap_fmt = sysinfo_format_memory (swap_total, swap_free);
    }

    mem_fmt = sysinfo_format_memory (mem_total, mem_free);

    if (swap_fmt)
    {
        ret = g_strdup_printf ("Physical: %s Swap: %s", mem_fmt, swap_fmt);
        g_free (mem_fmt);
        g_free (swap_fmt);
    }
    else
        ret = mem_fmt;

    return ret;
}
Example #2
0
static char *get_memory_info (void)
{
	MEMORYSTATUSEX meminfo = { 0 };
	meminfo.dwLength = sizeof (meminfo);

	if (!GlobalMemoryStatusEx (&meminfo))
	{
		return NULL;
	}

	return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
}