mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-25 06:09:38 +03:00
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
This commit is contained in:
parent
26ae9dbd12
commit
c32a58a826
@ -7,6 +7,7 @@
|
||||
* src/winio.c (edit_draw): When the whole line has been coloured,
|
||||
don't bother looking for any more starts. This prevents some lines
|
||||
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>
|
||||
* src/winio.c (get_key_buffer): Add some debugging code to make it
|
||||
|
@ -405,8 +405,7 @@ char *do_browse_from(const char *inpath)
|
||||
|
||||
/* If we can't open the path, get out. */
|
||||
if (dir == NULL) {
|
||||
if (path != NULL)
|
||||
free(path);
|
||||
free(path);
|
||||
beep();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -70,10 +70,8 @@ void set_colorpairs(void)
|
||||
interface_color_pair[i].pairnum = A_NORMAL;
|
||||
}
|
||||
|
||||
if (specified_color_combo[i] != NULL) {
|
||||
free(specified_color_combo[i]);
|
||||
specified_color_combo[i] = NULL;
|
||||
}
|
||||
free(specified_color_combo[i]);
|
||||
specified_color_combo[i] = NULL;
|
||||
}
|
||||
|
||||
for (; this_syntax != NULL; this_syntax = this_syntax->next) {
|
||||
|
18
src/files.c
18
src/files.c
@ -830,10 +830,8 @@ 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,
|
||||
* since its text has been saved. */
|
||||
fileptr = fileptr->prev;
|
||||
if (fileptr != NULL) {
|
||||
if (fileptr->next != NULL)
|
||||
free(fileptr->next);
|
||||
}
|
||||
if (fileptr != NULL)
|
||||
free(fileptr->next);
|
||||
}
|
||||
|
||||
/* Attach the line at current after the line at fileptr. */
|
||||
@ -1454,8 +1452,7 @@ char *get_full_path(const char *origpath)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@ -2177,8 +2174,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
|
||||
cleanup_and_exit:
|
||||
free(realname);
|
||||
if (tempname != NULL)
|
||||
free(tempname);
|
||||
free(tempname);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -2401,10 +2397,8 @@ bool do_writeout(bool exiting)
|
||||
* string's real length. */
|
||||
unsunder(answer, answer_len);
|
||||
|
||||
if (full_filename != NULL)
|
||||
free(full_filename);
|
||||
if (full_answer != NULL)
|
||||
free(full_answer);
|
||||
free(full_filename);
|
||||
free(full_answer);
|
||||
|
||||
if (do_warning) {
|
||||
/* If we're using restricted mode, we aren't allowed
|
||||
|
27
src/global.c
27
src/global.c
@ -1580,32 +1580,25 @@ void thanks_for_all_the_fish(void)
|
||||
delwin(bottomwin);
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (quotestr != NULL)
|
||||
free(quotestr);
|
||||
free(quotestr);
|
||||
#ifdef HAVE_REGEX_H
|
||||
regfree("ereg);
|
||||
if (quoteerr != NULL)
|
||||
free(quoteerr);
|
||||
free(quoteerr);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (backup_dir != NULL)
|
||||
free(backup_dir);
|
||||
free(backup_dir);
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (operating_dir != NULL)
|
||||
free(operating_dir);
|
||||
if (full_operating_dir != NULL)
|
||||
free(full_operating_dir);
|
||||
free(operating_dir);
|
||||
free(full_operating_dir);
|
||||
#endif
|
||||
free(answer);
|
||||
free(last_search);
|
||||
free(last_replace);
|
||||
#ifndef DISABLE_SPELLER
|
||||
if (alt_speller != NULL)
|
||||
free(alt_speller);
|
||||
free(alt_speller);
|
||||
#endif
|
||||
if (answer != NULL)
|
||||
free(answer);
|
||||
if (cutbuffer != NULL)
|
||||
free_filestruct(cutbuffer);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@ -1616,8 +1609,7 @@ void thanks_for_all_the_fish(void)
|
||||
if (openfile != NULL)
|
||||
free_openfilestruct(openfile);
|
||||
#ifndef DISABLE_COLOR
|
||||
if (syntaxstr != NULL)
|
||||
free(syntaxstr);
|
||||
free(syntaxstr);
|
||||
while (syntaxes != NULL) {
|
||||
syntaxtype *bill = syntaxes;
|
||||
|
||||
@ -1692,8 +1684,7 @@ void thanks_for_all_the_fish(void)
|
||||
free(s);
|
||||
}
|
||||
#ifndef DISABLE_NANORC
|
||||
if (homedir != NULL)
|
||||
free(homedir);
|
||||
free(homedir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -387,8 +387,7 @@ void help_init(void)
|
||||
|
||||
/* help_text has been freed and set to NULL unless the user resized
|
||||
* while in the help screen. */
|
||||
if (help_text != NULL)
|
||||
free(help_text);
|
||||
free(help_text);
|
||||
|
||||
/* Allocate space for the help text. */
|
||||
help_text = charalloc(allocsize + 1);
|
||||
|
12
src/nano.c
12
src/nano.c
@ -123,14 +123,10 @@ void delete_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->data != NULL);
|
||||
|
||||
if (fileptr->data != NULL)
|
||||
free(fileptr->data);
|
||||
|
||||
free(fileptr->data);
|
||||
#ifndef DISABLE_COLOR
|
||||
if (fileptr->multidata)
|
||||
free(fileptr->multidata);
|
||||
free(fileptr->multidata);
|
||||
#endif
|
||||
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
@ -572,10 +568,8 @@ void delete_opennode(openfilestruct *fileptr)
|
||||
free(fileptr->filename);
|
||||
free_filestruct(fileptr->fileage);
|
||||
#ifndef NANO_TINY
|
||||
if (fileptr->current_stat != NULL)
|
||||
free(fileptr->current_stat);
|
||||
free(fileptr->current_stat);
|
||||
#endif
|
||||
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
|
@ -918,8 +918,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
if (history_list != NULL) {
|
||||
history_reset(*history_list);
|
||||
|
||||
if (magichistory != NULL)
|
||||
free(magichistory);
|
||||
free(magichistory);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -977,8 +976,7 @@ int do_prompt(bool allow_tabs,
|
||||
|
||||
/* prompt has been freed and set to NULL unless the user resized
|
||||
* while at the statusbar prompt. */
|
||||
if (prompt != NULL)
|
||||
free(prompt);
|
||||
free(prompt);
|
||||
|
||||
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
|
||||
|
||||
|
@ -985,8 +985,7 @@ void parse_linter(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (endsyntax->linter != NULL)
|
||||
free(endsyntax->linter);
|
||||
free(endsyntax->linter);
|
||||
|
||||
/* Let them unset the linter by using "". */
|
||||
if (!strcmp(ptr, "\"\""))
|
||||
@ -1012,8 +1011,7 @@ void parse_formatter(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (endsyntax->formatter != NULL)
|
||||
free(endsyntax->formatter);
|
||||
free(endsyntax->formatter);
|
||||
|
||||
/* Let them unset the formatter by using "". */
|
||||
if (!strcmp(ptr, "\"\""))
|
||||
|
@ -885,8 +885,7 @@ void add_undo(undo_type current_action)
|
||||
while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
|
||||
undo *u2 = fs->undotop;
|
||||
fs->undotop = fs->undotop->next;
|
||||
if (u2->strdata != NULL)
|
||||
free(u2->strdata);
|
||||
free(u2->strdata);
|
||||
if (u2->cutbuffer)
|
||||
free_filestruct(u2->cutbuffer);
|
||||
free(u2);
|
||||
|
Loading…
Reference in New Issue
Block a user