Print this page
11506 smatch resync
*** 20,45 ****
static int my_id;
static unsigned long max_size;
! static void match_end_func(struct symbol *sym)
{
FILE *file;
char buf[1024];
unsigned long size;
file = fopen("/proc/self/statm", "r");
if (!file)
! return;
fread(buf, 1, sizeof(buf), file);
fclose(file);
size = strtoul(buf, NULL, 10);
size = size * sysconf(_SC_PAGESIZE) / 1024;
if (size > max_size)
max_size = size;
}
unsigned long get_max_memory(void)
{
return max_size;
--- 20,55 ----
static int my_id;
static unsigned long max_size;
! unsigned long get_mem_kb(void)
{
FILE *file;
char buf[1024];
unsigned long size;
file = fopen("/proc/self/statm", "r");
if (!file)
! 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;