pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / zoneinfo / ialloc.c
blob074fca4f940da748fdf30580c84059d36e67c916
3 /*LINTLIBRARY*/
5 #include <string.h>
6 #include <stdlib.h>
8 #include "stdio.h"
10 #ifndef lint
11 #ifndef NOID
12 static char sccsid[] = "@(#)ialloc.c 7.14";
13 #endif /* !NOID */
14 #endif /* !lint */
16 #ifndef alloc_t
17 #define alloc_t unsigned
18 #endif /* !alloc_t */
20 #ifdef MAL
21 #define NULLMAL(x) ((x) == NULL || (x) == MAL)
22 #else /* !MAL */
23 #define NULLMAL(x) ((x) == NULL)
24 #endif /* !MAL */
26 #if 0
27 extern char * calloc();
28 extern char * malloc();
29 extern char * realloc();
30 extern char * strcpy();
31 #endif
33 char *
34 imalloc(int n)
36 #ifdef MAL
37 register char * result;
39 if (n == 0)
40 n = 1;
41 result = malloc((alloc_t) n);
42 return (result == MAL) ? NULL : result;
43 #else /* !MAL */
44 if (n == 0)
45 n = 1;
46 return malloc((alloc_t) n);
47 #endif /* !MAL */
50 char *
51 icalloc(int nelem, int elsize)
53 if (nelem == 0 || elsize == 0)
54 nelem = elsize = 1;
55 return calloc((alloc_t) nelem, (alloc_t) elsize);
58 char *
59 irealloc(char *pointer, int size)
61 if (NULLMAL(pointer))
62 return imalloc(size);
63 if (size == 0)
64 size = 1;
65 return realloc(pointer, (alloc_t) size);
68 char *
69 icatalloc(char *old, char *new)
71 register char * result;
72 register oldsize, newsize;
74 oldsize = NULLMAL(old) ? 0 : strlen(old);
75 newsize = NULLMAL(new) ? 0 : strlen(new);
76 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
77 if (!NULLMAL(new))
78 (void) strcpy(result + oldsize, new);
79 return result;
82 char *
83 icpyalloc(char *string)
85 return icatalloc((char *) NULL, string);
88 ifree(char *p)
90 if (!NULLMAL(p))
91 free(p);
94 icfree(char *p)
96 if (!NULLMAL(p))
97 free(p);