nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] My good buddy Uriah -- multibuffers switched, not copied


From: Steven Kneizys
Subject: [Nano-devel] My good buddy Uriah -- multibuffers switched, not copied
Date: Mon, 18 Feb 2002 17:34:43 -0800 (PST)

I roughed out changing from doing a copy_filestruct to just changing
the pointer fileage, and after taking out some of my previous changes
to plug memory leaks it was pretty easy to do.  Plus, I noticed that my
free(path) fix was wrong, anyway here those changes are here.  I do not
know all the implications of the fileage pointer change, but I know
that in debug mode the switching of 5000 line files took seconds
instead of a couple mins ;-)

One thing not in the patch attached in the #ifndef for multibuffers
would need to be put back around the free(fileage) code in my routine
'thanks_for_the_memories' as they would be freed by the multibuffers
free above it and we shouldn't re-free them.  

have fun,

Steve...

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
--- files.c.afterbuffer_fix_1   Mon Feb 18 19:28:46 2002
+++ files.c     Mon Feb 18 20:02:14 2002
@@ -406,7 +406,7 @@
               that could create them are taken care of elsewhere) */
            add_open_file(1, 0);
 
-           free_filestruct(fileage);
+/* spk     free_filestruct(fileage); */
            new_file();
            UNSET(MODIFIED);
        }
@@ -568,8 +568,9 @@
        /* save current filestruct and restore full file position
           afterward */
 /*     open_files->file = nmalloc(sizeof(filestruct));/* */
-       if (open_files->file != NULL) free_filestruct(open_files->file);
-       open_files->file = copy_filestruct(fileage);
+/*     if (open_files->file != NULL) free_filestruct(open_files->file);*/
+/*     open_files->file = copy_filestruct(fileage); */
+       open_files->file = fileage; /* SPK testing 1 2 3 */
        do_gotopos(open_files->lineno, open_files->file_current_x, 
open_files->file_current_y, open_files->file_placewewant);
     }
 
@@ -614,7 +615,8 @@
     /* set up the filename, the file buffer, the total number of lines in
        the file, and the total file size */
     filename = mallocstrcpy(filename, open_files->data);
-    fileage = copy_filestruct(open_files->file);
+/*    fileage = copy_filestruct(open_files->file); /* spk try less */
+    fileage = open_files->file;
     current = fileage;
     totlines = open_files->file_totlines;
     totsize = open_files->file_totsize;
@@ -683,18 +685,20 @@
 
        if (!strcmp(tmp->file_path, path)) {
 
-           free(path);
-           if (!update)
+           if (!update){
                /* if we're making a new entry and there's an entry with
                   the same full path, we've found a duplicate */
+               free(path);
                return tmp;
-           else {
+           } else {
 
                /* if we're updating an existing entry and there's an
                   entry with the same full path that isn't the current
                   entry, we've found a duplicate */
-               if (tmp != open_files) 
+               if (tmp != open_files) {
+                   free(path);
                    return tmp;
+               }
            }
        }
 
@@ -787,7 +791,7 @@
 
     }
 
-    free_filestruct(fileage);/* delete this before reloading */
+/*    free_filestruct(fileage);/* delete this before reloading */
     load_open_file();
 
 #ifdef DEBUG
@@ -850,7 +854,7 @@
        }
     }
 
-    free_filestruct(fileage);/* delete this before reloading */
+/*    free_filestruct(fileage);/* delete this before reloading */
     load_open_file();
 
 #ifdef DEBUG

reply via email to

[Prev in Thread] Current Thread [Next in Thread]