1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-27 05:10:36 +00:00

Implement the low memory profile when RAM is lower than 352 MB.

PR:		ports/166422
Submitted by:	Olivier Duchateau
Feature safe:	yes
This commit is contained in:
Rene Ladan 2012-03-26 21:11:55 +00:00
parent b53124fb35
commit d69a2379f2
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=293867
2 changed files with 51 additions and 0 deletions

View File

@ -8,6 +8,7 @@
PORTNAME= midori
PORTVERSION= 0.4.4
PORTREVISION= 1
CATEGORIES= www xfce
MASTER_SITES= ${MASTER_SITE_XFCE}
MASTER_SITE_SUBDIR= src/apps/${PORTNAME}/${PORTVERSION:R}

View File

@ -0,0 +1,50 @@
--- midori/midori-websettings.c.orig 2012-03-08 23:34:45.000000000 +0100
+++ midori/midori-websettings.c 2012-03-23 15:48:54.000000000 +0100
@@ -27,6 +27,11 @@
#include <sys/utsname.h>
#endif
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
struct _MidoriWebSettings
{
WebKitWebSettings parent_instance;
@@ -347,16 +352,26 @@
static gboolean
midori_web_settings_low_memory_profile ()
{
- gchar* contents;
- const gchar* total;
- if (!g_file_get_contents ("/proc/meminfo", &contents, NULL, NULL))
- return FALSE;
- if (contents && (total = strstr (contents, "MemTotal:")) && *total)
- {
- const gchar* value = katze_skip_whitespace (total + 9);
- gdouble mem_total = g_ascii_strtoll (value, NULL, 0);
- return mem_total / 1024.0 < 352 + 1;
- }
+ #ifdef __FreeBSD__
+ size_t size;
+ int mem_total;
+ size = sizeof mem_total;
+
+ sysctlbyname("hw.realmem", &mem_total, &size, NULL, 0);
+
+ return mem_total / 1048576 < 352;
+ #else
+ gchar* contents;
+ const gchar* total;
+ if (!g_file_get_contents ("/proc/meminfo", &contents, NULL, NULL))
+ return FALSE;
+ if (contents && (total = strstr (contents, "MemTotal:")) && *total)
+ {
+ const gchar* value = katze_skip_whitespace (total + 9);
+ gdouble mem_total = g_ascii_strtoll (value, NULL, 0);
+ return mem_total / 1024.0 < 352 + 1;
+ }
+ #endif
return FALSE;
}