-static bool below_threshold(const long ram_total, const long ram_used, const char *threshold_type, const long low_threshold) {
- // empty is available or free, based on "use_available_memory"
- long empty = ram_total - ram_used;
- if (BEGINS_WITH(threshold_type, "percentage_")) {
- return 100.0 * empty / ram_total < low_threshold;
- } else if (strcasecmp(threshold_type, "bytes_free") == 0) {
- return empty < low_threshold;
- } else if (threshold_type[0] != '\0' && strncasecmp(threshold_type + 1, "bytes_", strlen("bytes_")) == 0) {
-
- long factor = 1;
-
- switch (threshold_type[0]) {
+static long memory_absolute(const long mem_total, const char *size) {
+ long mem_absolute = -1;
+ char *endptr = NULL;
+
+ mem_absolute = strtol(size, &endptr, 10);
+
+ if (endptr) {
+ while (endptr[0] != '\0' && isspace(endptr[0]))
+ endptr++;
+
+ switch (endptr[0]) {