Commit 3674c1da authored by Chris Allegretta's avatar Chris Allegretta
Browse files

- winio.c:edit_add() - Add in the necessary regfree() calls to stop nano from...

- winio.c:edit_add() - Add in the necessary regfree() calls to stop nano from leaking memory like a sieve when using color syntax highlighting :-)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1207 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 21 additions and 5 deletions
+21 -5
...@@ -74,6 +74,8 @@ CVS code - ...@@ -74,6 +74,8 @@ CVS code -
- winio.c: - winio.c:
edit_add() edit_add()
- Changed some syntax hilight computations for the sake of COLS. - Changed some syntax hilight computations for the sake of COLS.
- Add in the necessary regfree() calls to stop nano from leaking
memory like a sieve when using color syntax highlighting :-)
botombars(), onekey() botombars(), onekey()
- Cleanups (David Benbennick). - Cleanups (David Benbennick).
- po/gl.po: - po/gl.po:
......
...@@ -856,6 +856,8 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -856,6 +856,8 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
k += colormatches[0].rm_eo; k += colormatches[0].rm_eo;
} }
regfree(&color_regexp);
} }
/* Now, if there's an 'end' somewhere below, and a 'start' /* Now, if there's an 'end' somewhere below, and a 'start'
somewhere above, things get really fun. We have to look somewhere above, things get really fun. We have to look
...@@ -868,9 +870,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -868,9 +870,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
while (s != NULL) { while (s != NULL) {
regcomp(&color_regexp, tmpcolor->start, 0); regcomp(&color_regexp, tmpcolor->start, 0);
if (!regexec if (!regexec
(&color_regexp, s->data, 1, colormatches, 0)) (&color_regexp, s->data, 1, colormatches, 0)) {
regfree(&color_regexp);
break; break;
}
s = s->prev; s = s->prev;
regfree(&color_regexp);
} }
if (s != NULL) { if (s != NULL) {
...@@ -881,9 +886,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -881,9 +886,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
while (e != NULL && e != fileptr) { while (e != NULL && e != fileptr) {
regcomp(&color_regexp, tmpcolor->end, 0); regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec if (!regexec
(&color_regexp, e->data, 1, colormatches, 0)) (&color_regexp, e->data, 1, colormatches, 0)) {
regfree(&color_regexp);
break; break;
}
e = e->next; e = e->next;
regfree(&color_regexp);
} }
if (e != fileptr) if (e != fileptr)
...@@ -893,9 +901,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -893,9 +901,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
regcomp(&color_regexp, tmpcolor->end, 0); regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec if (!regexec
(&color_regexp, e->data, 1, colormatches, (&color_regexp, e->data, 1, colormatches,
0)) 0)) {
regfree(&color_regexp);
break; break;
}
e = e->next; e = e->next;
regfree(&color_regexp);
} }
if (e == NULL) if (e == NULL)
...@@ -907,9 +918,11 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -907,9 +918,11 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
regcomp(&color_regexp, tmpcolor->end, 0); regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec if (!regexec
(&color_regexp, e->data, 1, (&color_regexp, e->data, 1,
colormatches, 0)) colormatches, 0)) {
regfree(&color_regexp);
break; break;
e = e->next; } e = e->next;
regfree(&color_regexp);
} }
if (e == NULL) if (e == NULL)
...@@ -960,6 +973,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ...@@ -960,6 +973,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
} }
} }
#endif /* ENABLE_COLOR */ #endif /* ENABLE_COLOR */
#ifndef NANO_SMALL #ifndef NANO_SMALL
......
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