Condensing some code by factoring out a repetition.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5659 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
f4f9954556
commit
818a39cfb9
|
@ -1,5 +1,6 @@
|
||||||
2016-02-22 Benno Schulenberg <bensberg@justemail.net>
|
2016-02-22 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/nano.c (free_openfilestruct): Elide this function.
|
* src/nano.c (free_openfilestruct): Elide this function.
|
||||||
|
* scr/global.c (thanks_for_all_the_fish, free_list_item): Condense.
|
||||||
|
|
||||||
2016-02-21 Benno Schulenberg <bensberg@justemail.net>
|
2016-02-21 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/files.c (input_tab): If the first Tab added the part that all
|
* src/files.c (input_tab): If the first Tab added the part that all
|
||||||
|
|
39
src/global.c
39
src/global.c
|
@ -1623,6 +1623,17 @@ int strtomenu(const char *input)
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
#ifndef DISABLE_COLOR
|
||||||
|
void free_list_item(regexlisttype *dropit)
|
||||||
|
{
|
||||||
|
free(dropit->ext_regex);
|
||||||
|
if (dropit->ext != NULL)
|
||||||
|
regfree(dropit->ext);
|
||||||
|
free(dropit->ext);
|
||||||
|
free(dropit);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This function is used to gracefully return all the memory we've used.
|
/* This function is used to gracefully return all the memory we've used.
|
||||||
* It should be called just before calling exit(). Practically, the
|
* It should be called just before calling exit(). Practically, the
|
||||||
* only effect is to cause a segmentation fault if the various data
|
* only effect is to cause a segmentation fault if the various data
|
||||||
|
@ -1672,47 +1683,32 @@ void thanks_for_all_the_fish(void)
|
||||||
free(syntaxes->desc);
|
free(syntaxes->desc);
|
||||||
free(syntaxes->linter);
|
free(syntaxes->linter);
|
||||||
free(syntaxes->formatter);
|
free(syntaxes->formatter);
|
||||||
|
|
||||||
while (syntaxes->extensions != NULL) {
|
while (syntaxes->extensions != NULL) {
|
||||||
regexlisttype *bob = syntaxes->extensions;
|
regexlisttype *bob = syntaxes->extensions;
|
||||||
syntaxes->extensions = bob->next;
|
syntaxes->extensions = bob->next;
|
||||||
free(bob->ext_regex);
|
free_list_item(bob);
|
||||||
if (bob->ext != NULL) {
|
|
||||||
regfree(bob->ext);
|
|
||||||
free(bob->ext);
|
|
||||||
}
|
|
||||||
free(bob);
|
|
||||||
}
|
}
|
||||||
while (syntaxes->headers != NULL) {
|
while (syntaxes->headers != NULL) {
|
||||||
regexlisttype *bob = syntaxes->headers;
|
regexlisttype *bob = syntaxes->headers;
|
||||||
syntaxes->headers = bob->next;
|
syntaxes->headers = bob->next;
|
||||||
free(bob->ext_regex);
|
free_list_item(bob);
|
||||||
if (bob->ext != NULL) {
|
|
||||||
regfree(bob->ext);
|
|
||||||
free(bob->ext);
|
|
||||||
}
|
|
||||||
free(bob);
|
|
||||||
}
|
}
|
||||||
while (syntaxes->magics != NULL) {
|
while (syntaxes->magics != NULL) {
|
||||||
regexlisttype *bob = syntaxes->magics;
|
regexlisttype *bob = syntaxes->magics;
|
||||||
syntaxes->magics = bob->next;
|
syntaxes->magics = bob->next;
|
||||||
free(bob->ext_regex);
|
free_list_item(bob);
|
||||||
if (bob->ext != NULL) {
|
|
||||||
regfree(bob->ext);
|
|
||||||
free(bob->ext);
|
|
||||||
}
|
|
||||||
free(bob);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (syntaxes->color != NULL) {
|
while (syntaxes->color != NULL) {
|
||||||
colortype *bob = syntaxes->color;
|
colortype *bob = syntaxes->color;
|
||||||
|
|
||||||
syntaxes->color = bob->next;
|
syntaxes->color = bob->next;
|
||||||
free(bob->start_regex);
|
free(bob->start_regex);
|
||||||
if (bob->start != NULL) {
|
if (bob->start != NULL) {
|
||||||
regfree(bob->start);
|
regfree(bob->start);
|
||||||
free(bob->start);
|
free(bob->start);
|
||||||
}
|
}
|
||||||
if (bob->end_regex != NULL)
|
free(bob->end_regex);
|
||||||
free(bob->end_regex);
|
|
||||||
if (bob->end != NULL) {
|
if (bob->end != NULL) {
|
||||||
regfree(bob->end);
|
regfree(bob->end);
|
||||||
free(bob->end);
|
free(bob->end);
|
||||||
|
@ -1744,5 +1740,4 @@ void thanks_for_all_the_fish(void)
|
||||||
free(homedir);
|
free(homedir);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
Loading…
Reference in New Issue