<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -80,25 +80,27 @@ int main (int argc, char **argv) {
 				fscanf(fi, &quot;%p %lu\n&quot;, &amp;adr, &amp;size);
 				addH(h, adr, size);
 				fprintf(fo, &quot;USED\t%p\t%lu\n&quot;, adr, size);
-				fflush(fi);
 				break;
 			}
 			case 'f': {
 				fscanf(fi, &quot;%p&quot;, &amp;adr);
-				p = locH(h, adr);
-				if (p) {
+				if (adr) {
+                                    p = locH(h, adr);
+				    if (p) {
 					fprintf(fo, &quot;FREE\t%p\t%lu\n&quot;, adr, p-&gt;size);
 					delH(h,adr);
+				    }
+				    else fprintf(stderr, &quot;[%d]Free error: %p unallocated before\n&quot;, ++i,adr);
 				}
-				else fprintf(stderr, &quot;[%d]Free error: %p unallocated before\n&quot;, ++i,adr);
-				fflush(fi);
 				break;
 			}
 			case 'r': {
 				fscanf(fi, &quot;%p %p %lu&quot;, &amp;old, &amp;adr, &amp;size);
 				if (old==NULL &amp;&amp; size==0) break;
-				if (old==NULL) 
+				if (old==NULL) {
 					fprintf(fo, &quot;USED\t%p\t%lu\n&quot;, adr, size);
+                                        addH(h,adr,size);
+                                }
 				else if (size==0) {
 					p = locH(h, old);
 					if (p) fprintf(fo, &quot;FREE\t%p\t%lu\n&quot;, old, p-&gt;size);
@@ -114,7 +116,6 @@ int main (int argc, char **argv) {
 					}
 					else fprintf(stderr, &quot;[%d]Realloc error: %p unallocated before\n&quot;, ++i,old);
 				}
-				fflush(fi);
 				break;
 			}
 		}</diff>
      <filename>free_size.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,20 @@
 #!/bin/bash
 
-&gt; $2
+rm -f massif_output_file
 
-ms_print $1 | grep -e '0$' -e '%' | grep -v -e 'within' -e 'places' -e 'snapshots' -e '???'  | tr -s ' ' | while read a; do
+echo &quot;Valgrind is running ...&quot;
+
+G_SLICE=always-malloc valgrind --tool=massif --alloc-fn=g_mem_chunk_alloc --alloc-fn=g_malloc --alloc-fn=g_malloc0 --alloc-fn=g_realloc --time-unit=B --massif-out-file=massif_output_file $@ 2&gt; /dev/null
+
+ms_print massif_output_file | grep -e '0$' -e '%' | grep -v -e 'within' -e 'places' -e 'snapshots' -e '???'  | tr -s ' ' | while read a; do
 	if [[ $a =~ (^-&gt;) ]]; then
 		if ! [[ $a =~ (^-&gt;0) ]]; then
 			ok=1
 		else ok=0
 		fi
 	fi
-	if [[ $a =~ (0$) ]]; then echo -e &quot;\nSNAPSHOT:$a\n&quot; &gt;&gt; $2; fi
-	if (($ok)); then echo $a &gt;&gt; $2; fi
-done
\ No newline at end of file
+	if [[ $a =~ (0$) ]]; then echo -e &quot;\nSNAPSHOT:$a\n&quot;; fi
+	if (($ok)); then echo $a; fi
+done
+
+rm -f massif_output_file</diff>
      <filename>most_allocated.sh</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,15 @@ function find () {
   return ${#S[*]}
 }
 
-ms_print $1 | fgrep '.c:' | cut -d '(' -f3 | cut -d ')' -f1 |
+rm -f massif_output_file
+
+echo &quot;Valgrind is running ...&quot;
+
+G_SLICE=always-malloc valgrind --tool=massif --alloc-fn=g_mem_chunk_alloc --alloc-fn=g_malloc --alloc-fn=g_malloc0 --alloc-fn=g_realloc --time-unit=B --massif-out-file=massif_output_file $@ 2&gt; /dev/null
+
+echo -e &quot;Processing data ...\n&quot;
+
+ms_print massif_output_file | fgrep '.c:' | cut -d '(' -f3 | cut -d ')' -f1 |
 {
 
   while read line; do
@@ -31,3 +39,5 @@ ms_print $1 | fgrep '.c:' | cut -d '(' -f3 | cut -d ')' -f1 |
   echo -e $output | sort -n -r
 
 }
+
+rm -f massif_output_file</diff>
      <filename>most_allocations.sh</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>37681710bc780e9ad2353c870ed71abe867f7782</id>
    </parent>
  </parents>
  <author>
    <name>Andrei Soare</name>
    <email>andrei@andrei-laptop.(none)</email>
  </author>
  <url>http://github.com/asoare/bprof/commit/baf122535d570b4595d43d9c8cc3fd4088a0c102</url>
  <id>baf122535d570b4595d43d9c8cc3fd4088a0c102</id>
  <committed-date>2008-06-28T14:58:20-07:00</committed-date>
  <authored-date>2008-06-28T14:58:20-07:00</authored-date>
  <message>* fixed some bugs in free_size.c
* modified most_allocated.sh and most_allocations.sh to be easier to use
* added a readme file</message>
  <tree>059e37932e3280f1368a8fd6bdab0938a21d7393</tree>
  <committer>
    <name>Andrei Soare</name>
    <email>andrei@andrei-laptop.(none)</email>
  </committer>
</commit>
