From 83c99bece4efc3be8f5616ab1b01107c9cb6645d Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 22 Aug 2012 21:57:07 +0200 Subject: [PATCH] cleanup wallace arrays on program termination --- src/frontend/trannoise/wallace.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/frontend/trannoise/wallace.c b/src/frontend/trannoise/wallace.c index 6d5c74b27..f1b5f8b50 100644 --- a/src/frontend/trannoise/wallace.c +++ b/src/frontend/trannoise/wallace.c @@ -70,6 +70,13 @@ void PolarGauss(double* py1, double* py2) +static void destroy_wallace(void) +{ + tfree(pool1); + tfree(pool2); + tfree(addrif); + tfree(addrib); +} void initw(void) @@ -87,11 +94,13 @@ void initw(void) newpools = 1; /* set up the two pools */ - pool1 = TMALLOC(double, n); //(double*)malloc(n * sizeof(double)); - pool2 = TMALLOC(double, n); //(double*)malloc(n * sizeof(double)); - addrif = TMALLOC(unsigned int, (n + NOTRANS)); //(unsigned int*)malloc((n + NOTRANS) * sizeof(unsigned int)); - addrib = TMALLOC(unsigned int, (n + NOTRANS)); //(unsigned int*)malloc((n + NOTRANS) * sizeof(unsigned int)); - + pool1 = TMALLOC(double, n); + pool2 = TMALLOC(double, n); + addrif = TMALLOC(unsigned int, (n + NOTRANS)); + addrib = TMALLOC(unsigned int, (n + NOTRANS)); + + atexit(destroy_wallace); + /* fill the first pool with normally distributed values */ PolarGauss(&pool1[0], &pool1[1]); for (i = 1; i < n>>1; i++) {