Deleted Added
full compact
memalloc.c (17987) memalloc.c (18018)
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

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

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
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

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

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $Id: memalloc.c,v 1.2 1994/09/24 02:57:50 davidg Exp $
36 * $Id: memalloc.c,v 1.3 1996/09/01 10:20:42 peter Exp $
37 */
38
39#ifndef lint
40static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
41#endif /* not lint */
42
43#include "shell.h"
44#include "output.h"

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

202 * this block. Growstackblock will grow this space by at least one byte,
203 * possibly moving it (like realloc). Grabstackblock actually allocates the
204 * part of the block that has been used.
205 */
206
207void
208growstackblock() {
209 char *p;
37 */
38
39#ifndef lint
40static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
41#endif /* not lint */
42
43#include "shell.h"
44#include "output.h"

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

202 * this block. Growstackblock will grow this space by at least one byte,
203 * possibly moving it (like realloc). Grabstackblock actually allocates the
204 * part of the block that has been used.
205 */
206
207void
208growstackblock() {
209 char *p;
210 int newlen = stacknleft * 2 + 100;
210 int newlen = ALIGN(stacknleft * 2 + 100);
211 char *oldspace = stacknxt;
212 int oldlen = stacknleft;
213 struct stack_block *sp;
214
215 if (stacknxt == stackp->space && stackp != &stackbase) {
216 INTOFF;
217 sp = stackp;
218 stackp = sp->prev;
219 sp = ckrealloc((pointer)sp, sizeof(struct stack_block) - MINSIZE + newlen);
220 sp->prev = stackp;
221 stackp = sp;
222 stacknxt = sp->space;
223 stacknleft = newlen;
224 INTON;
225 } else {
226 p = stalloc(newlen);
227 memcpy(p, oldspace, oldlen);
228 stacknxt = p; /* free the space */
211 char *oldspace = stacknxt;
212 int oldlen = stacknleft;
213 struct stack_block *sp;
214
215 if (stacknxt == stackp->space && stackp != &stackbase) {
216 INTOFF;
217 sp = stackp;
218 stackp = sp->prev;
219 sp = ckrealloc((pointer)sp, sizeof(struct stack_block) - MINSIZE + newlen);
220 sp->prev = stackp;
221 stackp = sp;
222 stacknxt = sp->space;
223 stacknleft = newlen;
224 INTON;
225 } else {
226 p = stalloc(newlen);
227 memcpy(p, oldspace, oldlen);
228 stacknxt = p; /* free the space */
229 stacknleft += ALIGN(newlen); /* we just allocated */
229 stacknleft += newlen; /* we just allocated */
230 }
231}
232
233
234
235void
236grabstackblock(len)
237 int len;

--- 64 unchanged lines hidden ---
230 }
231}
232
233
234
235void
236grabstackblock(len)
237 int len;

--- 64 unchanged lines hidden ---