From 01d71d60b79027e1ce3eb9c79ae5191e1407c883 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 15 Jan 2008 17:46:59 +0200 Subject: [PATCH] Free the allocated memory in lzmadec if debugging is enabled. This should make it possible to detect possible memory leaks with Valgrind. --- src/lzmadec/lzmadec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lzmadec/lzmadec.c b/src/lzmadec/lzmadec.c index fef49249..f0ae3568 100644 --- a/src/lzmadec/lzmadec.c +++ b/src/lzmadec/lzmadec.c @@ -513,5 +513,12 @@ main(int argc, char **argv) } while (++optind < argc); } +#ifndef NDEBUG + // Free the memory only when debugging. Freeing wastes some time, + // but allows detecting possible memory leaks with Valgrind. + lzma_end(&strm); + lzma_memlimit_end(mem_limitter, false); +#endif + return exit_status; }