Deleted Added
full compact
memalloc.c (50471) memalloc.c (64702)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
40#endif
41static const char rcsid[] =
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
40#endif
41static const char rcsid[] =
42 "$FreeBSD: head/bin/sh/memalloc.c 50471 1999-08-27 23:15:48Z peter $";
42 "$FreeBSD: head/bin/sh/memalloc.c 64702 2000-08-16 10:39:43Z cracauer $";
43#endif /* not lint */
44
45#include "shell.h"
46#include "output.h"
47#include "memalloc.h"
48#include "error.h"
49#include "machdep.h"
50#include "mystring.h"

--- 62 unchanged lines hidden (view full) ---

113
114struct stack_block {
115 struct stack_block *prev;
116 char space[MINSIZE];
117};
118
119struct stack_block stackbase;
120struct stack_block *stackp = &stackbase;
43#endif /* not lint */
44
45#include "shell.h"
46#include "output.h"
47#include "memalloc.h"
48#include "error.h"
49#include "machdep.h"
50#include "mystring.h"

--- 62 unchanged lines hidden (view full) ---

113
114struct stack_block {
115 struct stack_block *prev;
116 char space[MINSIZE];
117};
118
119struct stack_block stackbase;
120struct stack_block *stackp = &stackbase;
121struct stackmark *markp;
121char *stacknxt = stackbase.space;
122int stacknleft = MINSIZE;
123int sstrnleft;
124int herefd = -1;
125
126
127
128pointer

--- 42 unchanged lines hidden (view full) ---

171
172void
173setstackmark(mark)
174 struct stackmark *mark;
175{
176 mark->stackp = stackp;
177 mark->stacknxt = stacknxt;
178 mark->stacknleft = stacknleft;
122char *stacknxt = stackbase.space;
123int stacknleft = MINSIZE;
124int sstrnleft;
125int herefd = -1;
126
127
128
129pointer

--- 42 unchanged lines hidden (view full) ---

172
173void
174setstackmark(mark)
175 struct stackmark *mark;
176{
177 mark->stackp = stackp;
178 mark->stacknxt = stacknxt;
179 mark->stacknleft = stacknleft;
180 mark->marknext = markp;
181 markp = mark;
179}
180
181
182void
183popstackmark(mark)
184 struct stackmark *mark;
185{
186 struct stack_block *sp;
187
188 INTOFF;
182}
183
184
185void
186popstackmark(mark)
187 struct stackmark *mark;
188{
189 struct stack_block *sp;
190
191 INTOFF;
192 markp = mark->marknext;
189 while (stackp != mark->stackp) {
190 sp = stackp;
191 stackp = sp->prev;
192 ckfree(sp);
193 }
194 stacknxt = mark->stacknxt;
195 stacknleft = mark->stacknleft;
196 INTON;

--- 13 unchanged lines hidden (view full) ---

210void
211growstackblock()
212{
213 char *p;
214 int newlen;
215 char *oldspace;
216 int oldlen;
217 struct stack_block *sp;
193 while (stackp != mark->stackp) {
194 sp = stackp;
195 stackp = sp->prev;
196 ckfree(sp);
197 }
198 stacknxt = mark->stacknxt;
199 stacknleft = mark->stacknleft;
200 INTON;

--- 13 unchanged lines hidden (view full) ---

214void
215growstackblock()
216{
217 char *p;
218 int newlen;
219 char *oldspace;
220 int oldlen;
221 struct stack_block *sp;
222 struct stack_block *oldstackp;
218
219 newlen = ALIGN(stacknleft * 2 + 100);
220 oldspace = stacknxt;
221 oldlen = stacknleft;
222
223 if (stacknxt == stackp->space && stackp != &stackbase) {
224 INTOFF;
223
224 newlen = ALIGN(stacknleft * 2 + 100);
225 oldspace = stacknxt;
226 oldlen = stacknleft;
227
228 if (stacknxt == stackp->space && stackp != &stackbase) {
229 INTOFF;
230 oldstackp = stackp;
225 sp = stackp;
226 stackp = sp->prev;
227 sp = ckrealloc((pointer)sp, sizeof(struct stack_block) -
228 MINSIZE + newlen);
229 sp->prev = stackp;
230 stackp = sp;
231 stacknxt = sp->space;
232 stacknleft = newlen;
231 sp = stackp;
232 stackp = sp->prev;
233 sp = ckrealloc((pointer)sp, sizeof(struct stack_block) -
234 MINSIZE + newlen);
235 sp->prev = stackp;
236 stackp = sp;
237 stacknxt = sp->space;
238 stacknleft = newlen;
239 {
240 /* Stack marks pointing to the start of the old block
241 * must be relocated to point to the new block
242 */
243 struct stackmark *xmark;
244 xmark = markp;
245 while (xmark != NULL && xmark->stackp == oldstackp) {
246 xmark->stackp = stackp;
247 xmark->stacknxt = stacknxt;
248 xmark->stacknleft = stacknleft;
249 xmark = xmark->marknext;
250 }
251 }
233 INTON;
234 } else {
235 p = stalloc(newlen);
236 memcpy(p, oldspace, oldlen);
237 stacknxt = p; /* free the space */
238 stacknleft += newlen; /* we just allocated */
239 }
240}

--- 76 unchanged lines hidden ---
252 INTON;
253 } else {
254 p = stalloc(newlen);
255 memcpy(p, oldspace, oldlen);
256 stacknxt = p; /* free the space */
257 stacknleft += newlen; /* we just allocated */
258 }
259}

--- 76 unchanged lines hidden ---