1 |
tdb |
1.1 |
/* e_realloc() -- Error checking realloc. */ |
2 |
|
|
|
3 |
|
|
/* Copyright 1992 Godfrey Paul, University of Kent at Canterbury. |
4 |
|
|
* |
5 |
|
|
* You can do what you like with this source code as long as |
6 |
|
|
* you don't try to make money out of it and you include an |
7 |
|
|
* unaltered copy of this message (including the copyright). |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
char ukcprog_realloc_sccsid[] = "$Id: e_realloc.c,v 1.8 1993/05/30 18:15:09 gjap Exp $ UKC"; |
11 |
|
|
|
12 |
|
|
#ifndef __STDC__ |
13 |
|
|
#include <sys/types.h> /* for size_t */ |
14 |
|
|
#endif |
15 |
|
|
|
16 |
|
|
#include <stdio.h> /* for NULL */ |
17 |
|
|
#include <stdlib.h> |
18 |
|
|
|
19 |
|
|
#include "ukcprog.h" |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
voidptr |
23 |
|
|
e_realloc(old, size) |
24 |
|
|
voidptr old; |
25 |
|
|
size_t size; |
26 |
|
|
{ |
27 |
|
|
char *new; |
28 |
|
|
|
29 |
|
|
if (old == NULL) |
30 |
|
|
return e_malloc(size); |
31 |
|
|
|
32 |
|
|
if (size == 0) { |
33 |
|
|
free(old); |
34 |
|
|
return NULL; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
if ((new = realloc(old, (size_t)size)) == NULL) |
38 |
|
|
panic("realloc failed in e_realloc"); |
39 |
|
|
|
40 |
|
|
return new; |
41 |
|
|
} |