]> git.wh0rd.org Git - nano.git/commitdiff
- winio.c:edit_add() - Add in the necessary regfree() calls to stop nano from leaking...
authorChris Allegretta <chrisa@asty.org>
Sun, 12 May 2002 20:43:49 +0000 (20:43 +0000)
committerChris Allegretta <chrisa@asty.org>
Sun, 12 May 2002 20:43:49 +0000 (20:43 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1207 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
winio.c

index 17846f6bc66059c68bf1ad90d4ce365181de649d..e7392b33bd5fd984882b15438f399e07f5dc02e3 100644 (file)
--- 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 0b84735ed0d4b64da71d267e8dce8be71fba2ba2..5eadd6a1f882bac99339cff3c2725fe4b93de826 100644 (file)
--- 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