#! /bin/sh
# The SPIMS software is covered by a license. The use of the software
# represents acceptance of the terms and conditions in the license.
# ******************************************************************
# Copyright (c) 1989, Swedish Institute of Computer Science
# Pair index from log file output for xmalloc and xfree
awk '
BEGIN { nindex = 0; }
$2 == "xmalloc" {
	i = substr($9, 1, length($9)-1);
	malloc[i]++;
	row[i] = $0;
	if (i > nindex)
		nindex = i;
}
$2 == "xfree" {
	i = substr($9, 1, length($9)-1);
	if (i > nindex)
		printf "xfree before malloc on %d\n", i;
	else
		malloc[i]--;
}
END {
	for (i = 1; i <= nindex; i++) {
		if (malloc[i]) {
			print malloc[i], row[i];
		}
	}
}
' $*
