Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Remeta one frame earlier



On Mon, 23 Feb 2015 15:32:55 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > If we do stick with the heap, I'm wondering if we need to free it more
> > often than we do.  Maybe the freeheap() below should be if (uselex ||
> > remeta), and maybe it should be right at the end of the loop for
> > safety.
> 
> I'll leave this part to you... At least nothing after the freeheap()
> uses pt, so it shouldn't be any less safe than before™.

pws

diff --git a/Src/hist.c b/Src/hist.c
index c530e72..aa07ce8 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2593,8 +2593,6 @@ readhistfile(char *fn, int err, int readflags)
 	    start = pt;
 	    uselex = isset(HISTLEXWORDS) && !(readflags & HFILE_FAST);
 	    histsplitwords(pt, &words, &nwords, &nwordpos, uselex);
-	    if (uselex)
-		freeheap();
 
 	    he->nwords = nwordpos/2;
 	    if (he->nwords) {
@@ -2607,6 +2605,12 @@ readhistfile(char *fn, int err, int readflags)
 		freehistnode(&he->node);
 		curhist--;
 	    }
+	    /*
+	     * Do this last out of paranoia in case use of
+	     * heap is disguised...
+	     */
+	    if (uselex || remeta)
+		freeheap();
 	}
 	if (start && readflags & HFILE_USE_OPTIONS) {
 	    zsfree(lasthist.text);



Messages sorted by: Reverse Date, Date, Thread, Author