From ad640caac60bcb000ea0647b77f809a714aaaad2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 30 Jul 2021 13:38:39 -0700 Subject: Removing DEBUG_HEAP, just do a full cleanup all the time --- Makefile | 3 +-- bp.c | 4 ---- match.c | 2 -- match.h | 2 -- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 24f9ca0..0a9cb22 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,7 @@ clean: test: $(NAME) ./$(NAME) -g ./grammars/bp.bp -p Grammar ./grammars/bp.bp -leaktest: - make G=-ggdb O=-O0 EXTRA=-DDEBUG_HEAP clean bp +leaktest: bp valgrind --leak-check=full ./bp -l -g ./grammars/bp.bp -p Grammar ./grammars/bp.bp splint: diff --git a/bp.c b/bp.c index 4f29e4e..64990a6 100644 --- a/bp.c +++ b/bp.c @@ -408,10 +408,8 @@ static int process_file(def_t *defs, const char *filename, pat_t *pattern) fflush(stdout); cache_destroy(); -#ifdef DEBUG_HEAP if (recycle_all_matches() != 0) fprintf(stderr, "\033[33;1mMemory leak: there should no longer be any matches in use at this point.\033[0m\n"); -#endif destroy_file(&f); (void)fflush(stdout); return matches; @@ -668,7 +666,6 @@ int main(int argc, char *argv[]) if (tty_out) { (void)fclose(tty_out); tty_out = NULL; } if (tty_in) { (void)fclose(tty_in); tty_in = NULL; } -#ifdef DEBUG_HEAP // This code frees up all residual heap-allocated memory. Since the program // is about to exit, this step is unnecessary. However, it is useful for // tracking down memory leaks. @@ -680,7 +677,6 @@ int main(int argc, char *argv[]) destroy_file(&loaded_files); loaded_files = next; } -#endif exit(found > 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/match.c b/match.c index 62ad3fd..2531163 100644 --- a/match.c +++ b/match.c @@ -763,7 +763,6 @@ void recycle_if_unused(match_t **at_m) *at_m = NULL; } -#ifdef DEBUG_HEAP // // Force all match objects into the pool of unused match objects. // @@ -796,6 +795,5 @@ size_t free_all_matches(void) } return count; } -#endif // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 diff --git a/match.h b/match.h index 8c9b812..3b4b9d5 100644 --- a/match.h +++ b/match.h @@ -15,10 +15,8 @@ __attribute__((nonnull)) match_t *get_capture(match_t *m, const char **id); __attribute__((nonnull)) void recycle_if_unused(match_t **at_m); -#ifdef DEBUG_HEAP size_t free_all_matches(void); size_t recycle_all_matches(void); -#endif void cache_destroy(void); #endif -- cgit v1.2.3