# 2.11BSD#431 - /usr/src/share/zoneinfo/ialloc.c

##### Functions

    icalloc           X
    icatalloc         X
    icpyalloc         X
    ifree             X
    imalloc           X
    irealloc          X

##### Macros

    NULLMAL           X
    alloc_t           X

       1: /*
       2:  *	@(#)ialloc.c	1.1 ialloc.c 3/4/87
       3:  */
       4:
       5: /*LINTLIBRARY*/
       6:
       7: #include "stdio.h"
       8:
       9: #ifndef alloc_t
      10: #define alloc_t unsigned
      11: #endif /* !alloc_t */
      12:
      13: #ifdef MAL
      14: #define NULLMAL(x)  ((x) == NULL || (x) == MAL)
      15: #else /* !MAL */
      16: #define NULLMAL(x)  ((x) == NULL)
      17: #endif /* !MAL */
      18:
      19: extern char *   calloc();
      20: extern char *   malloc();
      21: extern char *   realloc();
      22: extern char *   strcpy();
      23:
      24: char *
      25: imalloc(n)
      26: {
      27: #ifdef MAL
      28:     register char * result;
      29:
      30:     if (n == 0)
      31:         n = 1;
      32:     result = malloc((alloc_t) n);
      33:     return (result == MAL) ? NULL : result;
      34: #else /* !MAL */
      35:     if (n == 0)
      36:         n = 1;
      37:     return malloc((alloc_t) n);
      38: #endif /* !MAL */
      39: }
      40:
      41: char *
      42: icalloc(nelem, elsize)
      43: {
      44:     if (nelem == 0 || elsize == 0)
      45:         nelem = elsize = 1;
      46:     return calloc((alloc_t) nelem, (alloc_t) elsize);
      47: }
      48:
      49: char *
      50: irealloc(pointer, size)
      51: char *  pointer;
      52: {
      53:     if (NULLMAL(pointer))
      54:         return imalloc(size);
      55:     if (size == 0)
      56:         size = 1;
      57:     return realloc(pointer, (alloc_t) size);
      58: }
      59:
      60: char *
      61: icatalloc(old, new)
      62: char *  old;
      63: char *  new;
      64: {
      65:     register char * result;
      66:     register    oldsize, newsize;
      67:
      68:     oldsize = NULLMAL(old) ? 0 : strlen(old);
      69:     newsize = NULLMAL(new) ? 0 : strlen(new);
      70:     if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
      71:         if (!NULLMAL(new))
      72:             (void) strcpy(result + oldsize, new);
      73:     return result;
      74: }
      75:
      76: char *
      77: icpyalloc(string)
      78: char *  string;
      79: {
      80:     return icatalloc((char *) NULL, string);
      81: }
      82:
      83: ifree(p)
      84: char *  p;
      85: {
      86:     if (!NULLMAL(p))
      87:         free(p);
      88: }

#### Defined functions

icalloc defined in line 41; never used
icatalloc defined in line 60; used 1 times

- in line 80

icpyalloc defined in line 76; used 2 times

- in /usr/src/share/zoneinfo/zic.c line 23, 303

ifree defined in line 83; never used
imalloc defined in line 24; used 7 times

- in line 54
- in /usr/src/share/zoneinfo/scheck.c line 10, 27
- in /usr/src/share/zoneinfo/zdump.c line 19, 93
- in /usr/src/share/zoneinfo/zic.c line 24, 301

irealloc defined in line 49; used 3 times

- in line 70
- in /usr/src/share/zoneinfo/zic.c line 25, 302

#### Defined macros

NULLMAL defined in line 16; used 5 times

- in line 53, 68-71(3), 86

alloc_t defined in line 10; used 6 times

- in line 9, 32-37(2), 46(2), 57

Last modified: 1987-03-31 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1127 |