memalloc.c (18018) | memalloc.c (20425) |
---|---|
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.3 1996/09/01 10:20:42 peter Exp $ | 36 * $Id: memalloc.c,v 1.4 1996/09/03 14:15:53 peter Exp $ |
37 */ 38 39#ifndef lint | 37 */ 38 39#ifndef lint |
40static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; | 40static char const sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; |
41#endif /* not lint */ 42 43#include "shell.h" 44#include "output.h" 45#include "memalloc.h" 46#include "error.h" 47#include "machdep.h" 48#include "mystring.h" 49#include <stdlib.h> 50#include <unistd.h> 51 52/* 53 * Like malloc, but returns an error when out of space. 54 */ 55 56pointer | 41#endif /* not lint */ 42 43#include "shell.h" 44#include "output.h" 45#include "memalloc.h" 46#include "error.h" 47#include "machdep.h" 48#include "mystring.h" 49#include <stdlib.h> 50#include <unistd.h> 51 52/* 53 * Like malloc, but returns an error when out of space. 54 */ 55 56pointer |
57ckmalloc(nbytes) | 57ckmalloc(nbytes) |
58 int nbytes; 59{ 60 register pointer p; 61 62 if ((p = malloc(nbytes)) == NULL) 63 error("Out of space"); 64 return p; 65} --- 53 unchanged lines hidden (view full) --- 119char *stacknxt = stackbase.space; 120int stacknleft = MINSIZE; 121int sstrnleft; 122int herefd = -1; 123 124 125 126pointer | 58 int nbytes; 59{ 60 register pointer p; 61 62 if ((p = malloc(nbytes)) == NULL) 63 error("Out of space"); 64 return p; 65} --- 53 unchanged lines hidden (view full) --- 119char *stacknxt = stackbase.space; 120int stacknleft = MINSIZE; 121int sstrnleft; 122int herefd = -1; 123 124 125 126pointer |
127stalloc(nbytes) | 127stalloc(nbytes) |
128 int nbytes; 129{ 130 register char *p; 131 132 nbytes = ALIGN(nbytes); 133 if (nbytes > stacknleft) { 134 int blocksize; 135 struct stack_block *sp; --- 92 unchanged lines hidden (view full) --- 228 stacknxt = p; /* free the space */ 229 stacknleft += newlen; /* we just allocated */ 230 } 231} 232 233 234 235void | 128 int nbytes; 129{ 130 register char *p; 131 132 nbytes = ALIGN(nbytes); 133 if (nbytes > stacknleft) { 134 int blocksize; 135 struct stack_block *sp; --- 92 unchanged lines hidden (view full) --- 228 stacknxt = p; /* free the space */ 229 stacknleft += newlen; /* we just allocated */ 230 } 231} 232 233 234 235void |
236grabstackblock(len) | 236grabstackblock(len) |
237 int len; 238{ 239 len = ALIGN(len); 240 stacknxt += len; 241 stacknleft -= len; 242} 243 244 --- 57 unchanged lines hidden --- | 237 int len; 238{ 239 len = ALIGN(len); 240 stacknxt += len; 241 stacknleft -= len; 242} 243 244 --- 57 unchanged lines hidden --- |