aboutsummaryrefslogtreecommitdiffstats
path: root/test/memleak.awk
diff options
context:
space:
mode:
Diffstat (limited to 'test/memleak.awk')
-rw-r--r--test/memleak.awk20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/memleak.awk b/test/memleak.awk
new file mode 100644
index 00000000..3937658f
--- /dev/null
+++ b/test/memleak.awk
@@ -0,0 +1,20 @@
+# This program doesn't do anything except allow us to
+# check for memory leak from using a user-supplied
+# sorting function.
+#
+# From Andrew Schorr.
+
+function my_func(i1, v1, i2, v2) {
+ return v2-v1
+}
+
+BEGIN {
+ a[1] = "3"
+ a[2] = "2"
+ a[3] = "4"
+ for (i = 0; i < 10000; i++) {
+ n = asort(a, b, "my_func")
+ s += n
+ }
+ print s
+}