memalloc.c (6195fb4102afbdfc3da8c0ac2e4cacb0f37d89a9) memalloc.c (670528cd789a9ce3d51e32edddc02e6b7ff358f9)
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

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

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

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

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

--- 239 unchanged lines hidden ---
93/*
94 * Make a copy of a string in safe storage.
95 */
96
97char *
98savestr(char *s)
99{
100 char *p;

--- 239 unchanged lines hidden ---