#!/usr/bin/perl -w

my $filename=$ARGV[0] || "info";

#system "make";
#system "./tryserver.sh >$filename";


my %allocated;
my %lineok;




open IN,"<$filename";
my $line=0;
while(<IN>)
{
  if(m/^ALLOC.*\((\w+)\)/)
  {
    $allocated{$1}=$line;
  }
  elsif(m/^FREE.*\((\w+)\)/)
  {
    if($allocated{$1})
    {
      $lineok{$allocated{$1}}=1;
      $lineok{$line}=1;
      undef $allocated{$1};
    }
  }
  $line++;
}
close IN;


open OUT,">$filename.htm";

open IN,"<$filename";
$line=0;
while(<IN>)
{
  chomp;
  if(m/^ALLOC.*\((\w+)\)/ or m/^FREE.*\((\w+)\)/)
  {
    if($lineok{$line})
    {
      my $show=0;
      foreach($line-10 .. $line+10)
      {
        $show=1 if(not $lineok{$_});
      }
      if($show)
      {
        print OUT "<font color='#00ff00'>$_</font><br/>\n"
      }
      else
      {
        print OUT ".";
      }
    }
    else
    {
      print OUT "<font color='#ff0000'>$_</font><br/>\n";
    }
  }
  else
  {
    print OUT "$_<br/>\n";
  }
  $line++;
}
close IN;

close OUT;

system "konqueror $filename.htm";

