19 |
# include "config.h" |
# include "config.h" |
20 |
#endif |
#endif |
21 |
|
|
|
#if __STDC__ |
|
|
#define VOID void |
|
|
#else |
|
|
#define VOID char |
|
|
#endif |
|
|
|
|
22 |
#include <sys/types.h> |
#include <sys/types.h> |
23 |
|
|
24 |
#if STDC_HEADERS |
#if STDC_HEADERS |
25 |
#include <stdlib.h> |
#include <stdlib.h> |
26 |
#else |
#else |
27 |
VOID *malloc (); |
void *malloc (); |
28 |
VOID *realloc (); |
void *realloc (); |
29 |
void free (); |
void free (); |
30 |
#endif |
#endif |
31 |
|
|
43 |
void error (); |
void error (); |
44 |
#endif |
#endif |
45 |
|
|
46 |
static VOID * |
static void * |
47 |
fixup_null_alloc (n) |
fixup_null_alloc (size_t n) |
|
size_t n; |
|
48 |
{ |
{ |
49 |
VOID *p; |
void *p; |
50 |
|
|
51 |
p = 0; |
p = 0; |
52 |
if (n == 0) |
if (n == 0) |
58 |
|
|
59 |
/* Allocate N bytes of memory dynamically, with error checking. */ |
/* Allocate N bytes of memory dynamically, with error checking. */ |
60 |
|
|
61 |
VOID * |
void * |
62 |
xmalloc (n) |
xmalloc (size_t n) |
|
size_t n; |
|
63 |
{ |
{ |
64 |
VOID *p; |
void *p; |
65 |
|
|
66 |
p = malloc (n); |
p = malloc (n); |
67 |
if (p == 0) |
if (p == 0) |
73 |
with error checking. |
with error checking. |
74 |
If P is NULL, run xmalloc. */ |
If P is NULL, run xmalloc. */ |
75 |
|
|
76 |
VOID * |
void * |
77 |
xrealloc (p, n) |
xrealloc (void *p, size_t n) |
|
VOID *p; |
|
|
size_t n; |
|
78 |
{ |
{ |
79 |
if (p == 0) |
if (p == 0) |
80 |
return xmalloc (n); |
return xmalloc (n); |