summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expand.c6
-rw-r--r--src/memalloc.c26
-rw-r--r--src/memalloc.h2
-rw-r--r--src/parser.c3
4 files changed, 11 insertions, 26 deletions
diff --git a/src/expand.c b/src/expand.c
index 98ad718..e3e5d8f 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -546,10 +546,8 @@ expbackq(union node *cmd, int flag)
 	struct stackmark smark;
 
 	INTOFF;
-	setstackmark(&smark);
-	dest = expdest;
-	startloc = dest - (char *)stackblock();
-	grabstackstr(dest);
+	startloc = expdest - (char *)stackblock();
+	pushstackmark(&smark, startloc);
 	evalbackcmd(cmd, (struct backcmd *) &in);
 	popstackmark(&smark);
 
diff --git a/src/memalloc.c b/src/memalloc.c
index c8147d3..8d3e2ed 100644
--- a/src/memalloc.c
+++ b/src/memalloc.c
@@ -106,7 +106,6 @@ struct stack_block {
 
 struct stack_block stackbase;
 struct stack_block *stackp = &stackbase;
-struct stackmark *markp;
 char *stacknxt = stackbase.space;
 size_t stacknleft = MINSIZE;
 char *sstrend = stackbase.space + MINSIZE;
@@ -161,14 +160,17 @@ stunalloc(pointer p)
 
 
 
-void
-setstackmark(struct stackmark *mark)
+void pushstackmark(struct stackmark *mark, size_t len)
 {
 	mark->stackp = stackp;
 	mark->stacknxt = stacknxt;
 	mark->stacknleft = stacknleft;
-	mark->marknext = markp;
-	markp = mark;
+	grabstackblock(len);
+}
+
+void setstackmark(struct stackmark *mark)
+{
+	pushstackmark(mark, stacknxt == stackp->space && stackp != &stackbase);
 }
 
 
@@ -178,7 +180,6 @@ popstackmark(struct stackmark *mark)
 	struct stack_block *sp;
 
 	INTOFF;
-	markp = mark->marknext;
 	while (stackp != mark->stackp) {
 		sp = stackp;
 		stackp = sp->prev;
@@ -214,7 +215,6 @@ growstackblock(void)
 
 	if (stacknxt == stackp->space && stackp != &stackbase) {
 		struct stack_block *oldstackp;
-		struct stackmark *xmark;
 		struct stack_block *sp;
 		struct stack_block *prevstackp;
 		size_t grosslen;
@@ -230,18 +230,6 @@ growstackblock(void)
 		stacknxt = sp->space;
 		stacknleft = newlen;
 		sstrend = sp->space + newlen;
-
-		/*
-		 * Stack marks pointing to the start of the old block
-		 * must be relocated to point to the new block 
-		 */
-		xmark = markp;
-		while (xmark != NULL && xmark->stackp == oldstackp) {
-			xmark->stackp = stackp;
-			xmark->stacknxt = stacknxt;
-			xmark->stacknleft = stacknleft;
-			xmark = xmark->marknext;
-		}
 		INTON;
 	} else {
 		char *oldspace = stacknxt;
diff --git a/src/memalloc.h b/src/memalloc.h
index 282dbb0..ad6015d 100644
--- a/src/memalloc.h
+++ b/src/memalloc.h
@@ -40,7 +40,6 @@ struct stackmark {
 	struct stack_block *stackp;
 	char *stacknxt;
 	size_t stacknleft;
-	struct stackmark *marknext;
 };
 
 
@@ -54,6 +53,7 @@ pointer ckrealloc(pointer, size_t);
 char *savestr(const char *);
 pointer stalloc(size_t);
 void stunalloc(pointer);
+void pushstackmark(struct stackmark *mark, size_t len);
 void setstackmark(struct stackmark *);
 void popstackmark(struct stackmark *);
 void growstackblock(void);
diff --git a/src/parser.c b/src/parser.c
index f49ee7d..d0e0553 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1487,8 +1487,7 @@ setprompt(int which)
 	show = !el;
 #endif
 	if (show) {
-		setstackmark(&smark);
-		stalloc(stackblocksize());
+		pushstackmark(&smark, stackblocksize());
 		out2str(getprompt(NULL));
 		popstackmark(&smark);
 	}