diff --git a/ChangeLog b/ChangeLog index 17846f6b..e7392b33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -74,6 +74,8 @@ CVS code - - winio.c: edit_add() - 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() - Cleanups (David Benbennick). - po/gl.po: diff --git a/winio.c b/winio.c index 0b84735e..5eadd6a1 100644 --- a/winio.c +++ b/winio.c @@ -856,6 +856,8 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, k += colormatches[0].rm_eo; } + regfree(&color_regexp); + } /* Now, if there's an 'end' somewhere below, and a 'start' 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, while (s != NULL) { regcomp(&color_regexp, tmpcolor->start, 0); if (!regexec - (&color_regexp, s->data, 1, colormatches, 0)) + (&color_regexp, s->data, 1, colormatches, 0)) { + regfree(&color_regexp); break; + } s = s->prev; + regfree(&color_regexp); } if (s != NULL) { @@ -881,9 +886,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, while (e != NULL && e != fileptr) { regcomp(&color_regexp, tmpcolor->end, 0); if (!regexec - (&color_regexp, e->data, 1, colormatches, 0)) + (&color_regexp, e->data, 1, colormatches, 0)) { + regfree(&color_regexp); break; + } e = e->next; + regfree(&color_regexp); } if (e != fileptr) @@ -893,9 +901,12 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, regcomp(&color_regexp, tmpcolor->end, 0); if (!regexec (&color_regexp, e->data, 1, colormatches, - 0)) + 0)) { + regfree(&color_regexp); break; + } e = e->next; + regfree(&color_regexp); } if (e == NULL) @@ -907,9 +918,11 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, regcomp(&color_regexp, tmpcolor->end, 0); if (!regexec (&color_regexp, e->data, 1, - colormatches, 0)) + colormatches, 0)) { + regfree(&color_regexp); break; - e = e->next; + } e = e->next; + regfree(&color_regexp); } if (e == NULL) @@ -960,6 +973,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, } } + #endif /* ENABLE_COLOR */ #ifndef NANO_SMALL