[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] tweaks: don't bother having debug code that dealloc
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] tweaks: don't bother having debug code that deallocates all memory |
Date: |
Wed, 8 Aug 2018 20:07:22 +0200 |
Because: who runs debug builds for any length of time?
---
src/global.c | 111 ---------------------------------------------------
src/nano.c | 11 +++--
src/proto.h | 3 --
3 files changed, 7 insertions(+), 118 deletions(-)
diff --git a/src/global.c b/src/global.c
index 6df22d9c..60dbd37c 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1745,114 +1745,3 @@ int strtomenu(const char *input)
return -1;
}
#endif /* ENABLE_NANORC */
-
-
-#ifdef DEBUG
-/* This function is used to gracefully return all the memory we've used.
- * It should be called just before calling exit(). Practically, the
- * only effect is to cause a segmentation fault if the various data
- * structures got bolloxed earlier. Thus, we don't bother having this
- * function unless debugging is turned on. */
-void thanks_for_all_the_fish(void)
-{
- if (topwin != NULL)
- delwin(topwin);
- delwin(edit);
- delwin(bottomwin);
-
- free(word_chars);
-#ifdef ENABLE_JUSTIFY
- free(quotestr);
- regfree("ereg);
- free(quoteerr);
-#endif
-#ifndef NANO_TINY
- free(backup_dir);
-#endif
-#ifdef ENABLE_OPERATINGDIR
- free(operating_dir);
-#endif
- free(answer);
- free(last_search);
- free(present_path);
-#ifdef ENABLE_SPELLER
- free(alt_speller);
-#endif
- free_filestruct(cutbuffer);
-#ifdef ENABLE_MULTIBUFFER
- /* Free the memory associated with each open file buffer. */
- while (openfile != openfile->next) {
- openfile = openfile->next;
- delete_opennode(openfile->prev);
- }
- delete_opennode(openfile);
-#endif
-#ifdef ENABLE_COLOR
- free(syntaxstr);
- while (syntaxes != NULL) {
- syntaxtype *sint = syntaxes;
- syntaxes = syntaxes->next;
-
- free(sint->name);
- free(sint->linter);
- free(sint->formatter);
-
- while (sint->extensions != NULL) {
- regexlisttype *item = sint->extensions;
- sint->extensions = sint->extensions->next;
- free(item->full_regex);
- free(item);
- }
- while (sint->headers != NULL) {
- regexlisttype *item = sint->headers;
- sint->headers = sint->headers->next;
- free(item->full_regex);
- free(item);
- }
- while (sint->magics != NULL) {
- regexlisttype *item = sint->magics;
- sint->magics = sint->magics->next;
- free(item->full_regex);
- free(item);
- }
-
- while (sint->color != NULL) {
- colortype *ink = sint->color;
- sint->color = sint->color->next;
- free(ink->start_regex);
- if (ink->start != NULL) {
- regfree(ink->start);
- free(ink->start);
- }
- free(ink->end_regex);
- if (ink->end != NULL) {
- regfree(ink->end);
- free(ink->end);
- }
- free(ink);
- }
-
- free(sint);
- }
-#endif /* ENABLE_COLOR */
-#ifdef ENABLE_HISTORIES
- /* Free the search, replace, and execute history lists. */
- free_filestruct(searchtop);
- free_filestruct(replacetop);
- free_filestruct(executetop);
-#endif
- /* Free the list of functions. */
- while (allfuncs != NULL) {
- subnfunc *f = allfuncs;
- allfuncs = allfuncs->next;
- free(f);
- }
- /* Free the list of shortcuts. */
- while (sclist != NULL) {
- sc *s = sclist;
- sclist = sclist->next;
- free(s);
- }
- free(homedir);
-}
-#endif /* DEBUG */
diff --git a/src/nano.c b/src/nano.c
index ca1cf0a6..0e7f4bab 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -566,6 +566,13 @@ void finish(void)
blank_bottombars();
wrefresh(bottomwin);
+#ifndef NANO_TINY
+ /* Deallocate the two or three subwindows. */
+ if (topwin != NULL)
+ delwin(topwin);
+ delwin(edit);
+ delwin(bottomwin);
+#endif
/* Switch on the cursor and exit from curses mode. */
curs_set(1);
endwin();
@@ -582,10 +589,6 @@ void finish(void)
}
#endif
-#ifdef DEBUG
- thanks_for_all_the_fish();
-#endif
-
/* Get out. */
exit(0);
}
diff --git a/src/proto.h b/src/proto.h
index d30afa34..47cfdbdd 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -330,9 +330,6 @@ const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
sc *strtosc(const char *input);
int strtomenu(const char *input);
-#ifdef DEBUG
-void thanks_for_all_the_fish(void);
-#endif
/* All functions in help.c. */
#ifdef ENABLE_HELP
--
2.17.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] [PATCH] tweaks: don't bother having debug code that deallocates all memory,
Benno Schulenberg <=