Commit c32a58a8 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Not checking for non-NULL before freeing a variable, as it's unnecessary.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5249 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Showing with 28 additions and 57 deletions
+28 -57
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* src/winio.c (edit_draw): When the whole line has been coloured, * src/winio.c (edit_draw): When the whole line has been coloured,
don't bother looking for any more starts. This prevents some lines don't bother looking for any more starts. This prevents some lines
from being erroneously marked as CENDAFTER instead of CWHOLELINE. from being erroneously marked as CENDAFTER instead of CWHOLELINE.
* src/*.c: Don't check for non-NULL before freeing; it's unneeded.
2015-06-11 Benno Schulenberg <bensberg@justemail.net> 2015-06-11 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (get_key_buffer): Add some debugging code to make it * src/winio.c (get_key_buffer): Add some debugging code to make it
......
...@@ -405,7 +405,6 @@ char *do_browse_from(const char *inpath) ...@@ -405,7 +405,6 @@ char *do_browse_from(const char *inpath)
/* If we can't open the path, get out. */ /* If we can't open the path, get out. */
if (dir == NULL) { if (dir == NULL) {
if (path != NULL)
free(path); free(path);
beep(); beep();
return NULL; return NULL;
......
...@@ -70,11 +70,9 @@ void set_colorpairs(void) ...@@ -70,11 +70,9 @@ void set_colorpairs(void)
interface_color_pair[i].pairnum = A_NORMAL; interface_color_pair[i].pairnum = A_NORMAL;
} }
if (specified_color_combo[i] != NULL) {
free(specified_color_combo[i]); free(specified_color_combo[i]);
specified_color_combo[i] = NULL; specified_color_combo[i] = NULL;
} }
}
for (; this_syntax != NULL; this_syntax = this_syntax->next) { for (; this_syntax != NULL; this_syntax = this_syntax->next) {
colortype *this_color = this_syntax->color; colortype *this_color = this_syntax->color;
......
...@@ -830,11 +830,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw ...@@ -830,11 +830,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
/* Move fileptr back one line and blow away the old fileptr, /* Move fileptr back one line and blow away the old fileptr,
* since its text has been saved. */ * since its text has been saved. */
fileptr = fileptr->prev; fileptr = fileptr->prev;
if (fileptr != NULL) { if (fileptr != NULL)
if (fileptr->next != NULL)
free(fileptr->next); free(fileptr->next);
} }
}
/* Attach the line at current after the line at fileptr. */ /* Attach the line at current after the line at fileptr. */
if (fileptr != NULL) { if (fileptr != NULL) {
...@@ -1454,7 +1452,6 @@ char *get_full_path(const char *origpath) ...@@ -1454,7 +1452,6 @@ char *get_full_path(const char *origpath)
} }
/* Free d_there_file, since we're done using it. */ /* Free d_there_file, since we're done using it. */
if (d_there_file != NULL)
free(d_there_file); free(d_there_file);
return d_there; return d_there;
...@@ -2177,7 +2174,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type ...@@ -2177,7 +2174,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
cleanup_and_exit: cleanup_and_exit:
free(realname); free(realname);
if (tempname != NULL)
free(tempname); free(tempname);
return retval; return retval;
...@@ -2401,9 +2397,7 @@ bool do_writeout(bool exiting) ...@@ -2401,9 +2397,7 @@ bool do_writeout(bool exiting)
* string's real length. */ * string's real length. */
unsunder(answer, answer_len); unsunder(answer, answer_len);
if (full_filename != NULL)
free(full_filename); free(full_filename);
if (full_answer != NULL)
free(full_answer); free(full_answer);
if (do_warning) { if (do_warning) {
......
...@@ -1580,32 +1580,25 @@ void thanks_for_all_the_fish(void) ...@@ -1580,32 +1580,25 @@ void thanks_for_all_the_fish(void)
delwin(bottomwin); delwin(bottomwin);
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
if (quotestr != NULL)
free(quotestr); free(quotestr);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
regfree(&quotereg); regfree(&quotereg);
if (quoteerr != NULL)
free(quoteerr); free(quoteerr);
#endif #endif
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (backup_dir != NULL)
free(backup_dir); free(backup_dir);
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL)
free(operating_dir); free(operating_dir);
if (full_operating_dir != NULL)
free(full_operating_dir); free(full_operating_dir);
#endif #endif
free(answer);
free(last_search); free(last_search);
free(last_replace); free(last_replace);
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
if (alt_speller != NULL)
free(alt_speller); free(alt_speller);
#endif #endif
if (answer != NULL)
free(answer);
if (cutbuffer != NULL) if (cutbuffer != NULL)
free_filestruct(cutbuffer); free_filestruct(cutbuffer);
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
...@@ -1616,7 +1609,6 @@ void thanks_for_all_the_fish(void) ...@@ -1616,7 +1609,6 @@ void thanks_for_all_the_fish(void)
if (openfile != NULL) if (openfile != NULL)
free_openfilestruct(openfile); free_openfilestruct(openfile);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
if (syntaxstr != NULL)
free(syntaxstr); free(syntaxstr);
while (syntaxes != NULL) { while (syntaxes != NULL) {
syntaxtype *bill = syntaxes; syntaxtype *bill = syntaxes;
...@@ -1692,7 +1684,6 @@ void thanks_for_all_the_fish(void) ...@@ -1692,7 +1684,6 @@ void thanks_for_all_the_fish(void)
free(s); free(s);
} }
#ifndef DISABLE_NANORC #ifndef DISABLE_NANORC
if (homedir != NULL)
free(homedir); free(homedir);
#endif #endif
} }
......
...@@ -387,7 +387,6 @@ void help_init(void) ...@@ -387,7 +387,6 @@ void help_init(void)
/* help_text has been freed and set to NULL unless the user resized /* help_text has been freed and set to NULL unless the user resized
* while in the help screen. */ * while in the help screen. */
if (help_text != NULL)
free(help_text); free(help_text);
/* Allocate space for the help text. */ /* Allocate space for the help text. */
......
...@@ -123,14 +123,10 @@ void delete_node(filestruct *fileptr) ...@@ -123,14 +123,10 @@ void delete_node(filestruct *fileptr)
{ {
assert(fileptr != NULL && fileptr->data != NULL); assert(fileptr != NULL && fileptr->data != NULL);
if (fileptr->data != NULL)
free(fileptr->data); free(fileptr->data);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
if (fileptr->multidata)
free(fileptr->multidata); free(fileptr->multidata);
#endif #endif
free(fileptr); free(fileptr);
} }
...@@ -572,10 +568,8 @@ void delete_opennode(openfilestruct *fileptr) ...@@ -572,10 +568,8 @@ void delete_opennode(openfilestruct *fileptr)
free(fileptr->filename); free(fileptr->filename);
free_filestruct(fileptr->fileage); free_filestruct(fileptr->fileage);
#ifndef NANO_TINY #ifndef NANO_TINY
if (fileptr->current_stat != NULL)
free(fileptr->current_stat); free(fileptr->current_stat);
#endif #endif
free(fileptr); free(fileptr);
} }
......
...@@ -918,7 +918,6 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, ...@@ -918,7 +918,6 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
if (history_list != NULL) { if (history_list != NULL) {
history_reset(*history_list); history_reset(*history_list);
if (magichistory != NULL)
free(magichistory); free(magichistory);
} }
#endif #endif
...@@ -977,7 +976,6 @@ int do_prompt(bool allow_tabs, ...@@ -977,7 +976,6 @@ int do_prompt(bool allow_tabs,
/* prompt has been freed and set to NULL unless the user resized /* prompt has been freed and set to NULL unless the user resized
* while at the statusbar prompt. */ * while at the statusbar prompt. */
if (prompt != NULL)
free(prompt); free(prompt);
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1); prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
......
...@@ -985,7 +985,6 @@ void parse_linter(char *ptr) ...@@ -985,7 +985,6 @@ void parse_linter(char *ptr)
return; return;
} }
if (endsyntax->linter != NULL)
free(endsyntax->linter); free(endsyntax->linter);
/* Let them unset the linter by using "". */ /* Let them unset the linter by using "". */
...@@ -1012,7 +1011,6 @@ void parse_formatter(char *ptr) ...@@ -1012,7 +1011,6 @@ void parse_formatter(char *ptr)
return; return;
} }
if (endsyntax->formatter != NULL)
free(endsyntax->formatter); free(endsyntax->formatter);
/* Let them unset the formatter by using "". */ /* Let them unset the formatter by using "". */
......
...@@ -885,7 +885,6 @@ void add_undo(undo_type current_action) ...@@ -885,7 +885,6 @@ void add_undo(undo_type current_action)
while (fs->undotop != NULL && fs->undotop != fs->current_undo) { while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
undo *u2 = fs->undotop; undo *u2 = fs->undotop;
fs->undotop = fs->undotop->next; fs->undotop = fs->undotop->next;
if (u2->strdata != NULL)
free(u2->strdata); free(u2->strdata);
if (u2->cutbuffer) if (u2->cutbuffer)
free_filestruct(u2->cutbuffer); free_filestruct(u2->cutbuffer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment