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
Этот коммит содержится в:
родитель
26ae9dbd12
Коммит
c32a58a826
@ -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,8 +405,7 @@ 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,10 +70,8 @@ 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) {
|
||||||
|
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,
|
/* 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. */
|
||||||
@ -1454,8 +1452,7 @@ 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,8 +2174,7 @@ 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,10 +2397,8 @@ 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);
|
free(full_answer);
|
||||||
if (full_answer != NULL)
|
|
||||||
free(full_answer);
|
|
||||||
|
|
||||||
if (do_warning) {
|
if (do_warning) {
|
||||||
/* If we're using restricted mode, we aren't allowed
|
/* 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);
|
delwin(bottomwin);
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
if (quotestr != NULL)
|
free(quotestr);
|
||||||
free(quotestr);
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
regfree("ereg);
|
regfree("ereg);
|
||||||
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);
|
free(full_operating_dir);
|
||||||
if (full_operating_dir != NULL)
|
|
||||||
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,8 +1609,7 @@ 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,8 +1684,7 @@ 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,8 +387,7 @@ 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. */
|
||||||
help_text = charalloc(allocsize + 1);
|
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);
|
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)
|
|||||||
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,8 +918,7 @@ 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,8 +976,7 @@ 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,8 +985,7 @@ 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 "". */
|
||||||
if (!strcmp(ptr, "\"\""))
|
if (!strcmp(ptr, "\"\""))
|
||||||
@ -1012,8 +1011,7 @@ 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 "". */
|
||||||
if (!strcmp(ptr, "\"\""))
|
if (!strcmp(ptr, "\"\""))
|
||||||
|
@ -885,8 +885,7 @@ 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);
|
||||||
free(u2);
|
free(u2);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user