| 1 |
– |
/* Copyright 1988 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* ealloc.c - memory routines which call quit on error. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "copyright.h" |
| 9 |
|
|
| 10 |
+ |
|
| 11 |
|
#include <stdio.h> |
| 12 |
+ |
#include <stdlib.h> |
| 13 |
|
|
| 14 |
+ |
#include "rterror.h" |
| 15 |
+ |
#include "rtmisc.h" |
| 16 |
|
|
| 17 |
< |
char *malloc(), *realloc(), *emalloc(), *ecalloc(), *erealloc(); |
| 18 |
< |
|
| 17 |
< |
|
| 18 |
< |
char * |
| 19 |
< |
emalloc(n) /* return pointer to n uninitialized bytes */ |
| 20 |
< |
unsigned n; |
| 17 |
> |
extern void * /* return pointer to n uninitialized bytes */ |
| 18 |
> |
emalloc(size_t n) |
| 19 |
|
{ |
| 20 |
< |
register char *cp; |
| 20 |
> |
register void *cp; |
| 21 |
|
|
| 22 |
|
if (n == 0) |
| 23 |
|
return(NULL); |
| 27 |
|
|
| 28 |
|
eputs("Out of memory in emalloc\n"); |
| 29 |
|
quit(1); |
| 30 |
+ |
return NULL; /* pro forma return */ |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
|
| 34 |
< |
char * |
| 35 |
< |
ecalloc(ne, es) /* return pointer to initialized memory */ |
| 37 |
< |
register unsigned ne; |
| 38 |
< |
unsigned es; |
| 34 |
> |
extern void * /* return pointer to initialized memory */ |
| 35 |
> |
ecalloc(register size_t ne, size_t es) |
| 36 |
|
{ |
| 37 |
|
register char *cp; |
| 38 |
|
|
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
|
| 54 |
< |
char * |
| 55 |
< |
erealloc(cp, n) /* reallocate cp to size n */ |
| 59 |
< |
register char *cp; |
| 60 |
< |
unsigned n; |
| 54 |
> |
extern void * /* reallocate cp to size n */ |
| 55 |
> |
erealloc(register void *cp, size_t n) |
| 56 |
|
{ |
| 57 |
|
if (n == 0) { |
| 58 |
|
if (cp != NULL) |
| 70 |
|
|
| 71 |
|
eputs("Out of memory in erealloc\n"); |
| 72 |
|
quit(1); |
| 73 |
+ |
return NULL; /* pro forma return */ |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
< |
efree(cp) /* free memory allocated by above */ |
| 78 |
< |
char *cp; |
| 77 |
> |
extern void /* free memory allocated by above */ |
| 78 |
> |
efree(void *cp) |
| 79 |
|
{ |
| 80 |
|
free(cp); |
| 81 |
|
} |