CPU Percentage: after realloc the pointer becomes invalid; need to work on new pointer.
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 7 Jun 2014 14:57:50 +0000 (16:57 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 7 Jun 2014 14:57:50 +0000 (16:57 +0200)
fixes https://gist.github.com/toni-moreno/a2f80021535f87202de7

src/cpu.c

index 2e225fd..79dc150 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -241,10 +241,11 @@ static int cpu_states_grow (void)
          return -1;
   }
 
-  for (i = percents_cells; i < size; i++)
+  percents = tmp;
+
+  for (i = percents_cells ; i < size; i++)
          memset(&percents[i], 0, sizeof(*percents));
 
-  percents = tmp;
   percents_cells = size;
   return 0;
 } /* cpu_states_grow */