Print this page
11506 smatch resync

@@ -20,26 +20,36 @@
 
 static int my_id;
 
 static unsigned long max_size;
 
-static void match_end_func(struct symbol *sym)
+unsigned long get_mem_kb(void)
 {
         FILE *file;
         char buf[1024];
         unsigned long size;
 
         file = fopen("/proc/self/statm", "r");
         if (!file)
-                return;
+                return 0;
         fread(buf, 1, sizeof(buf), file);
         fclose(file);
 
         size = strtoul(buf, NULL, 10);
         size = size * sysconf(_SC_PAGESIZE) / 1024;
+        return size;
+}
+
+static void match_end_func(struct symbol *sym)
+{
+        unsigned long size;
+
+        if (option_mem) {
+                size = get_mem_kb();
         if (size > max_size)
                 max_size = size;
+        }
 }
 
 unsigned long get_max_memory(void)
 {
         return max_size;