# 2.11BSD#431 - /usr/ingres/source/equel/nalloc.c

##### Functions

    nalloc            X
    salloc            X
    xfree             X

       1: /*
       2: **  NALLOC.C -- Dynamic core allocation routines
       3: **
       4: **	Defines:
       5: **		nalloc()
       6: **		xfree()
       7: **		salloc()
       8: **
       9: **	History:
      10: **		77 -- (marc) written
      11: **		(xfree is modified from a routine
      12: **		stolen from bill joy)
      13: */
      14:
      15: /*
      16: **	NALLOC --
      17: **		Dynamic allocation routine which
      18: ** 		merely calls alloc(III), returning
      19: **		0 if no core and a pointer otherwise.
      20: **
      21: */
      22:
      23: char *nalloc(s)
      24: int s;
      25: {
      26:     extern char *malloc();
      27:
      28:     return (malloc(s));
      29: }
      30: /*
      31: **	SALLOC -- allocate
      32: **		place for string and initialize it,
      33: **		return string or 0 if no core.
      34: **
      35: */
      36:
      37: char *salloc(s)
      38: char        *s;
      39: {
      40:     register int        i;
      41:     register char       *string;
      42:     extern char     *malloc();
      43:
      44:     string = s;
      45:     i = (int) malloc(length(string) + 1);
      46:     if (i == 0)
      47:         return (0);
      48:
      49:     smove(string, i);
      50:     return ((char *)i);
      51: }
      52:
      53: /*
      54: **	XFREE -- Free possibly dynamic storage
      55: **		checking if its in the heap first.
      56: **
      57: **		0 - freed
      58: **		1 - not in heap
      59: **
      60: */
      61:
      62: xfree(cp)
      63: char        *cp;
      64: {
      65:     extern          end;    /* break (II) */
      66:     register char       *lcp, *lend, *lacp;
      67:
      68:     lcp = cp;
      69:     lacp = (char *) &cp;
      70:     lend = (char *) &end;
      71:     if (lcp >= lend && lcp < lacp)  /* make sure its in heap */
      72:     {
      73:         free(lcp);
      74:         return (0);
      75:     }
      76:     return (1);
      77: }

#### Defined functions

nalloc defined in line 23; used 8 times

- in /usr/ingres/source/equel/cvar.c line 33, 138
- in /usr/ingres/source/equel/display.c line 92-94(2)
- in /usr/ingres/source/equel/include.c line 131, 140
- in /usr/ingres/source/equel/retrieve.c line 107, 115

salloc defined in line 37; used 15 times

- in /usr/ingres/source/equel/cvar.c line 33, 144
- in /usr/ingres/source/equel/display.c line 398
- in /usr/ingres/source/equel/grammar.y line 606, 612, 713, 738
- in /usr/ingres/source/equel/include.c line 131, 165
- in /usr/ingres/source/equel/name.c line 107, 131
- in /usr/ingres/source/equel/number.c line 123, 137
- in /usr/ingres/source/equel/retrieve.c line 83
- in /usr/ingres/source/equel/string.c line 97

xfree defined in line 62; used 20 times

- in /usr/ingres/source/equel/cvar.c line 82-83(2), 110-111(2), 147, 211-212(2), 365-366(2)
- in /usr/ingres/source/equel/display.c line 187-188(2), 223-224(2)
- in /usr/ingres/source/equel/include.c line 174-177(2), 237, 248
- in /usr/ingres/source/equel/retrieve.c line 119, 187-188(2)

Last modified: 1995-04-14 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1068 |