+static unsigned long get_memlimit(const char *cgroup)
+{
+ char *memlimit_str = NULL;
+ unsigned long memlimit = -1;
+
+ if (cgm_get_value("memory", cgroup, "memory.limit_in_bytes", &memlimit_str))
+ memlimit = strtoul(memlimit_str, NULL, 10);
+
+ free(memlimit_str);
+
+ return memlimit;
+}
+
+static unsigned long get_min_memlimit(const char *cgroup)
+{
+ char *copy = strdupa(cgroup);
+ unsigned long memlimit = 0, retlimit;
+
+ retlimit = get_memlimit(copy);
+
+ while (strcmp(copy, "/") != 0) {
+ copy = dirname(copy);
+ memlimit = get_memlimit(copy);
+ if (memlimit != -1 && memlimit < retlimit)
+ retlimit = memlimit;
+ };
+
+ return retlimit;
+}
+