Deleted Added
full compact
memalloc.c (22988) memalloc.c (25222)
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$
36 * $Id: memalloc.c,v 1.7 1997/02/22 13:58:34 peter Exp $
37 */
38
39#ifndef lint
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"

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

52/*
53 * Like malloc, but returns an error when out of space.
54 */
55
56pointer
57ckmalloc(nbytes)
58 int nbytes;
59{
37 */
38
39#ifndef lint
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"

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

52/*
53 * Like malloc, but returns an error when out of space.
54 */
55
56pointer
57ckmalloc(nbytes)
58 int nbytes;
59{
60 register pointer p;
60 pointer p;
61
62 if ((p = malloc(nbytes)) == NULL)
63 error("Out of space");
64 return p;
65}
66
67
68/*
69 * Same for realloc.
70 */
71
72pointer
73ckrealloc(p, nbytes)
61
62 if ((p = malloc(nbytes)) == NULL)
63 error("Out of space");
64 return p;
65}
66
67
68/*
69 * Same for realloc.
70 */
71
72pointer
73ckrealloc(p, nbytes)
74 register pointer p;
74 pointer p;
75 int nbytes;
76{
77
78 if ((p = realloc(p, nbytes)) == NULL)
79 error("Out of space");
80 return p;
81}
82
83
84/*
85 * Make a copy of a string in safe storage.
86 */
87
88char *
89savestr(s)
90 char *s;
91 {
75 int nbytes;
76{
77
78 if ((p = realloc(p, nbytes)) == NULL)
79 error("Out of space");
80 return p;
81}
82
83
84/*
85 * Make a copy of a string in safe storage.
86 */
87
88char *
89savestr(s)
90 char *s;
91 {
92 register char *p;
92 char *p;
93
94 p = ckmalloc(strlen(s) + 1);
95 scopy(s, p);
96 return p;
97}
98
99
100/*

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

122int herefd = -1;
123
124
125
126pointer
127stalloc(nbytes)
128 int nbytes;
129{
93
94 p = ckmalloc(strlen(s) + 1);
95 scopy(s, p);
96 return p;
97}
98
99
100/*

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

122int herefd = -1;
123
124
125
126pointer
127stalloc(nbytes)
128 int nbytes;
129{
130 register char *p;
130 char *p;
131
132 nbytes = ALIGN(nbytes);
133 if (nbytes > stacknleft) {
134 int blocksize;
135 struct stack_block *sp;
136
137 blocksize = nbytes;
138 if (blocksize < MINSIZE)

--- 163 unchanged lines hidden ---
131
132 nbytes = ALIGN(nbytes);
133 if (nbytes > stacknleft) {
134 int blocksize;
135 struct stack_block *sp;
136
137 blocksize = nbytes;
138 if (blocksize < MINSIZE)

--- 163 unchanged lines hidden ---