Removing DEBUG_HEAP, just do a full cleanup all the time
This commit is contained in:
parent
f3954ac151
commit
ad640caac6
3
Makefile
3
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:
|
||||
|
4
bp.c
4
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);
|
||||
}
|
||||
|
2
match.c
2
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
|
||||
|
2
match.h
2
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
|
||||
|
Loading…
Reference in New Issue
Block a user