|
5 | 5 |
|
6 | 6 | #define nonzero(n) (((n) == 0) ? 1 : (n)) |
7 | 7 |
|
8 | | -char *imalloc(const int n) |
| 8 | +char * |
| 9 | +imalloc(const int n) |
9 | 10 | { |
10 | 11 | return malloc((size_t) nonzero(n)); |
11 | 12 | } |
12 | 13 |
|
13 | | -char *icalloc(int nelem, int elsize) |
| 14 | +char * |
| 15 | +icalloc(int nelem, int elsize) |
14 | 16 | { |
15 | 17 | if (nelem == 0 || elsize == 0) |
16 | 18 | nelem = elsize = 1; |
17 | 19 | return calloc((size_t) nelem, (size_t) elsize); |
18 | 20 | } |
19 | 21 |
|
20 | | -void *irealloc(void *pointer, const int size) |
| 22 | +void * |
| 23 | +irealloc(void *pointer, const int size) |
21 | 24 | { |
22 | 25 | if (pointer == NULL) |
23 | 26 | return imalloc(size); |
24 | 27 | return realloc((void *) pointer, (size_t) nonzero(size)); |
25 | 28 | } |
26 | 29 |
|
27 | | -char *icatalloc(char *old, const char *new) |
| 30 | +char * |
| 31 | +icatalloc(char *old, const char *new) |
28 | 32 | { |
29 | | - register char * result; |
30 | | - register int oldsize, newsize; |
| 33 | + register char *result; |
| 34 | + register int oldsize, |
| 35 | + newsize; |
31 | 36 |
|
32 | 37 | newsize = (new == NULL) ? 0 : strlen(new); |
33 | 38 | if (old == NULL) |
34 | 39 | oldsize = 0; |
35 | 40 | else if (newsize == 0) |
36 | 41 | return old; |
37 | | - else oldsize = strlen(old); |
| 42 | + else |
| 43 | + oldsize = strlen(old); |
38 | 44 | if ((result = irealloc(old, oldsize + newsize + 1)) != NULL) |
39 | 45 | if (new != NULL) |
40 | 46 | (void) strcpy(result + oldsize, new); |
41 | 47 | return result; |
42 | 48 | } |
43 | 49 |
|
44 | | -char *icpyalloc(const char *string) |
| 50 | +char * |
| 51 | +icpyalloc(const char *string) |
45 | 52 | { |
46 | 53 | return icatalloc((char *) NULL, string); |
47 | 54 | } |
48 | 55 |
|
49 | | -void ifree(char *p) |
| 56 | +void |
| 57 | +ifree(char *p) |
50 | 58 | { |
51 | 59 | if (p != NULL) |
52 | 60 | (void) free(p); |
53 | 61 | } |
54 | 62 |
|
55 | | -void icfree(char *p) |
| 63 | +void |
| 64 | +icfree(char *p) |
56 | 65 | { |
57 | 66 | if (p != NULL) |
58 | 67 | (void) free(p); |
|
0 commit comments