<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -73,6 +73,16 @@ int main (int argc, char **argv) {
 	Node *p;
 	int i=0;
 	
+    if (!fi) { 
+        printf(&quot;Invalid input file\n&quot;);
+        return 0;
+    }
+
+    if (!fo) {
+        printf(&quot;Invalid output file\n&quot;);
+        return 0;
+    }
+
 	initH(h);
 	while( fgets(s, 10, fi) ) // s will have a maximum size of 9: realloc\n\0
 		switch (s[0]) {</diff>
      <filename>free_size.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,13 @@
 #!/usr/bin/python
 
 from PIL import Image
+from sys import argv
 
 IMAGE_BASE_WIDTH = 75
 SCALE_IMAGE_BY = 6
 
 PAGE_SIZE = 4096
 PAGE_SHIFT = 12
-#PAGE_SIZE = 64
-#PAGE_SHIFT = 6
 
 class AllocationVisualizer:
     def __init__(self):
@@ -110,15 +109,33 @@ class AllocationVisualizer:
 def main():
     map = AllocationVisualizer()
 
-    imageIndex = 0
+    imageIndex = 1
+    opcount = 0
+    counter = 0
+    if len(argv) == 1:
+        nr_of_img = 1
+    elif len(argv) == 2:
+        nr_of_img = int (argv[1])
+    else:
+        print &quot;You must pass only one argument: the number of images you want to generate&quot;
+        raise Exception
 
     f = open(&quot;trace-out.txt&quot;, &quot;r&quot;)
-    opcount = 0
+
+    for line in f:
+        data = line.strip().split('\t')
+        if data[0] != &quot;USED&quot; and data[0] != &quot;FREE&quot;:
+            continue
+        opcount = opcount + 1
+    step = opcount / nr_of_img
+    
+    f.seek (0,0)
     for line in f:
         data = line.strip().split('\t')
         if data[0] != &quot;USED&quot; and data[0] != &quot;FREE&quot;:
             continue
 
+        counter = counter + 1
         state = (data[0] == &quot;USED&quot;)
         addr = int(data[1], 16)
         op = int(data[2])
@@ -126,7 +143,15 @@ def main():
             map.alloc(addr, op)
         else:
             map.free(addr, op)
-
+        if counter == imageIndex * step and imageIndex != nr_of_img:
+            im = map.makeImage(IMAGE_BASE_WIDTH)
+            newsize = im.size
+            w = newsize[0] * SCALE_IMAGE_BY
+            h = newsize[1] * SCALE_IMAGE_BY
+            im = im.resize((w, h), Image.NEAREST)
+            im.save(&quot;mem%03d.png&quot; % (imageIndex,), &quot;PNG&quot;)
+            imageIndex = imageIndex + 1
+            
     f.close()
 
     im = map.makeImage(IMAGE_BASE_WIDTH)</diff>
      <filename>memview.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c07753b1a1cf6459944582c8ec55ee1542d201a8</id>
    </parent>
  </parents>
  <author>
    <name>Andrei Soare</name>
    <email>andrei@andrei-laptop.(none)</email>
  </author>
  <url>http://github.com/asoare/bprof/commit/7d3ce7e275d385ab85994f1f2c4d9d2f07289bec</url>
  <id>7d3ce7e275d385ab85994f1f2c4d9d2f07289bec</id>
  <committed-date>2008-08-15T17:18:56-07:00</committed-date>
  <authored-date>2008-08-15T17:18:56-07:00</authored-date>
  <message>* improved memview.py, added the possibility to make progressive pictures
* the hooks need to make a log per PID</message>
  <tree>e7c2cb8e0d0d78990de9be9b1e8470b61a1bcbd1</tree>
  <committer>
    <name>Andrei Soare</name>
    <email>andrei@andrei-laptop.(none)</email>
  </committer>
</commit>
