cleanup wallace arrays on program termination

This commit is contained in:
rlar 2012-08-22 21:57:07 +02:00
parent 590fc543f8
commit 83c99bece4
1 changed files with 14 additions and 5 deletions

View File

@ -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++) {