From 81e4d3072c554f6d65874f6ed8fe130f5f31b1d7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 7 Mar 2013 13:42:19 +0900 Subject: [PATCH] Plug a bunch of memory leaks. Not that they really matter, but it makes reading valgrind's output a little easier. --- tools/qfvis/source/base-vis.c | 3 +-- tools/qfvis/source/qfvis.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/qfvis/source/base-vis.c b/tools/qfvis/source/base-vis.c index 6174ae9a5..6695b58e4 100644 --- a/tools/qfvis/source/base-vis.c +++ b/tools/qfvis/source/base-vis.c @@ -94,8 +94,6 @@ BasePortalVis (void) portal_t *tp, *portal; winding_t *winding; - if (portalsee) - set_delete (portalsee); portalsee = set_new_size (numportals * 2); for (i = 0, portal = portals; i < numportals * 2; i++, portal++) { portal->mightsee = set_new_size (portalclusters); @@ -133,4 +131,5 @@ BasePortalVis (void) SimpleFlood (portal, portal->cluster); portal->nummightsee = clustersee; } + set_delete (portalsee); } diff --git a/tools/qfvis/source/qfvis.c b/tools/qfvis/source/qfvis.c index 6654ef8e0..f5b5652e0 100644 --- a/tools/qfvis/source/qfvis.c +++ b/tools/qfvis/source/qfvis.c @@ -338,6 +338,7 @@ WatchThread (void *_thread) } } printf ("watch thread done\n"); + free (local_work); return NULL; } @@ -425,6 +426,8 @@ ClusterFlow (int clusternum) // expand to cluster->leaf PVS ClusterFlowExpand (visclusters, outbuffer); + set_delete (visclusters); + // compress the bit string if (options.verbosity > 0) printf ("cluster %4i : %4i visible\n", clusternum, numvis); @@ -482,6 +485,8 @@ CalcPortalVis (void) if (pthread_mutex_destroy (my_mutex) == -1) Sys_Error ("pthread_mutex_destroy failed"); + free (working); + free (my_mutex); } else { LeafThread (0); } @@ -909,5 +914,14 @@ main (int argc, char **argv) if (options.verbosity >= 0) printf ("%5.1f seconds elapsed\n", stop - start); + dstring_delete (portalfile); + dstring_delete (visdata); + dstring_delete (options.bspfile); + BSP_Free (bsp); + free (leafcluster); + free (uncompressed); + free (portals); + free (clusters); + return 0; }