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

PATCH: reallocation of prompt



Bart sent me a valgrind trace of a problem in the prompt code that I've
finally run to earth.

Index: Src/prompt.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v
retrieving revision 1.57
diff -u -r1.57 prompt.c
--- Src/prompt.c	24 Oct 2008 10:27:26 -0000	1.57
+++ Src/prompt.c	12 May 2009 19:50:53 -0000
@@ -841,6 +841,7 @@
     if((bv->bp - bv->buf) + need > bv->bufspc) {
 	int bo = bv->bp - bv->buf;
 	int bo1 = bv->bp1 ? bv->bp1 - bv->buf : -1;
+	ptrdiff_t bufline_off = bv->bufline ? bv->bufline - bv->buf : -1;
 
 	if(need & 255)
 	    need = (need | 255) + 1;
@@ -848,6 +849,8 @@
 	bv->bp = bv->buf + bo;
 	if(bo1 != -1)
 	    bv->bp1 = bv->buf + bo1;
+	if (bufline_off != -1)
+	    bv->bufline = bv->buf + bufline_off;
     }
 }
 

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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