diff options
author | Jürg Billeter <j@bitron.ch> | 2012-08-14 10:37:37 +0200 |
---|---|---|
committer | Martyn Russell <martyn@lanedo.com> | 2012-10-24 16:43:55 +0100 |
commit | c7e9b11b6404d2b370ead56424f65676cff5ebe5 (patch) | |
tree | 2048d97f7367260168fae299a216f6f269133251 | |
parent | 6c736a24d2ae150469df3c9a7b16245e007840c3 (diff) | |
download | tracker-c7e9b11b6404d2b370ead56424f65676cff5ebe5.tar.gz |
libtracker-common: Consistently use long in get_memory_total
-rw-r--r-- | src/libtracker-common/tracker-os-dependant-unix.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libtracker-common/tracker-os-dependant-unix.c b/src/libtracker-common/tracker-os-dependant-unix.c index 0baa421d9..5c36c71f7 100644 --- a/src/libtracker-common/tracker-os-dependant-unix.c +++ b/src/libtracker-common/tracker-os-dependant-unix.c @@ -222,7 +222,7 @@ tracker_create_permission_string (struct stat finfo) #ifndef DISABLE_MEM_LIMITS -static guint +static glong get_memory_total (void) { GError *error = NULL; @@ -253,17 +253,12 @@ get_memory_total (void) if (end) { *end = '\0'; - total = 1024 * atol (p); + total = 1024L * atol (p); } } g_free (contents); } - if (!total) { - /* Setting limit to an arbitary limit */ - total = RLIM_INFINITY; - } - return total; } @@ -279,9 +274,15 @@ tracker_memory_setrlimits (void) glong limit; total = get_memory_total (); + + if (!total) { + /* total amount of memory unknown */ + return FALSE; + } + total_halfed = total / 2; - /* Clamp memory between 50% of total and MAXLONG (2Gb) */ + /* Clamp memory between 50% of total and MAXLONG (2GB on 32-bit) */ limit = CLAMP (total_halfed, MEM_LIMIT_MIN, G_MAXLONG); /* We want to limit the max virtual memory |