diff -u -r nano/global.c nano-nofish/global.c --- nano/global.c Tue Apr 23 07:50:40 2002 +++ nano-nofish/global.c Wed Apr 24 02:30:45 2002 @@ -815,13 +815,15 @@ #endif } +/* This function is 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. + */ +#ifndef DEBUG /* added by SPK for memory cleanup, gracefully return our malloc()s */ void thanks_for_all_the_fish(void) { -#ifdef ENABLE_MULTIBUFFER - openfilestruct * current_open_file; -#endif - #ifndef DISABLE_OPERATINGDIR if (operating_dir != NULL) free(operating_dir); @@ -866,29 +868,21 @@ #endif #ifdef ENABLE_MULTIBUFFER -/* Cleanup of Multibuffers . . . - Do not cleanup the current one, that is fileage . . . do the - rest of them though! (should be none if all went well) */ - current_open_file = open_files; if (open_files != NULL) { - while (open_files->prev != NULL) + /* We free the memory associated with each open file. */ + openfilestruct *next; + + while (open_files->prev != NULL) open_files = open_files->prev; - while (open_files->next != NULL) { - /* cleanup of a multi buf . . . */ - open_files = open_files->next; - if (open_files->prev != current_open_file) - free_openfilestruct(open_files->prev); - } - /* cleanup of last multi buf . . . */ - free_openfilestruct(open_files); + do { + next = open_files->next; + free_openfilestruct(open_files); + open_files = next; + } while (open_files != NULL); } #else - /* starting the cleanup of fileage now . . . */ - if (fileage != NULL) free_filestruct(fileage); #endif - - /* that is all for now */ - } +#endif /* DEBUG */ diff -u -r nano/nano.c nano-nofish/nano.c --- nano/nano.c Tue Apr 23 07:50:40 2002 +++ nano-nofish/nano.c Wed Apr 24 02:30:46 2002 @@ -100,7 +100,9 @@ /* Restore the old term settings */ tcsetattr(0, TCSANOW, &oldterm); +#ifdef DEBUG thanks_for_all_the_fish(); +#endif exit(sigage); } diff -u -r nano/proto.h nano-nofish/proto.h --- nano/proto.h Tue Apr 23 07:50:40 2002 +++ nano-nofish/proto.h Wed Apr 24 02:30:46 2002 @@ -100,7 +100,9 @@ /* public functions in global.c */ int length_of_list(const shortcut *s); void shortcut_init(int unjustify); +#ifdef DEBUG void thanks_for_all_the_fish(void); +#endif