# 2.11BSD#431 - /usr/ingres/source/gutil/freebuf.c

##### Functions

    freebuf           X
    markbuf           X
    seterr            X

##### struct's

    nodbuffer         X

       1: /*
       2: **  FREEBUF.C -- more routines for LIFO dynamic buffer allocation [need.c]
       3: **
       4: **	These routines allow the deallocation of a need() type buffer,
       5: **	and also using the same buffer for various SERIALIZED purposes
       6: **	by marking the end of one, beginning of the next.
       7: **
       8: **	Defines:
       9: **		freebuf()
      10: **		markbuf()
      11: **		seterr()
      12: **
      13: **	Requires:
      14: **		that the buffer structure be IDENTICAL to that in [need.c]
      15: **
      16: **	History:
      17: **		10/12/78 -- (marc) separated from [need.c] so that processes
      18: **			not using more that need() and initbuf() wouldn't load
      19: **			it.
      20: */
      21:
      22:
      23:
      24:
      25:
      26:
      27: /* structure that the routines use to allocate space */
      28: struct nodbuffer
      29: {
      30:     int     nleft;      /* bytes left */
      31:     int     err_num;    /* error code on overflow */
      32:     int     (*err_func)();  /* error function on overflow */
      33:     char        *xfree;     /* next free byte */
      34:     char        buffer [];  /*beginning of buffer area */
      35: };
      36:
      37: /*
      38: **  MARKBUF -- Mark a place in the buffer to deallocate to
      39: **
      40: **	Parameters:
      41: **		bf -- buffer
      42: **
      43: **	Returns:
      44: **		int >= 0 marking place in buffer (should be used in calling
      45: **			freebuf())
      46: **
      47: **	Side Effects:
      48: **		none
      49: */
      50:
      51: markbuf(bf)
      52: struct nodbuffer    *bf;
      53: {
      54:     register struct nodbuffer   *buf;
      55:
      56:     buf = bf;
      57:     return (buf->nleft);
      58: }
      59:
      60:
      61: /*
      62: **  FREEBUF -- frees part of a buffer
      63: **
      64: **	Parameters:
      65: **		bf -- buffer
      66: **		bytes -- a previous return from markbuf().
      67: **
      68: **	Returns:
      69: **		none
      70: **
      71: **	Side Effects:
      72: **		none
      73: */
      74:
      75: freebuf(bf, bytes)
      76: struct nodbuffer    *bf;
      77: int         bytes;
      78: {
      79:     register struct nodbuffer   *buf;
      80:     register int            i;
      81:
      82:     buf = bf;
      83:     i = bytes - buf->nleft;
      84:     if (i < 0)
      85:         syserr("freebuf %d, %d", i, bytes);
      86:     buf->xfree -= i;
      87:     buf->nleft += i;
      88: }
      89:
      90: /*
      91: **  SETERR -- change the error info for a buffer
      92: **
      93: **	Parameters:
      94: **		bf -- buffer
      95: **		errnum -- new overflow error code
      96: **		err_func -- new error handler
      97: **
      98: **	Returns:
      99: **		none
     100: **
     101: **	Side Effects:
     102: **		adjusts buffer structure
     103: */
     104:
     105: seterr(bf, errnum, err_func)
     106: struct nodbuffer    *bf;
     107: int         errnum;
     108: int         (*err_func)();
     109: {
     110:     register struct nodbuffer   *buf;
     111:     register int            (*erf)();
     112:
     113:     buf = bf;
     114:     erf = err_func;
     115:     buf->err_num = errnum;
     116:     bf->err_func = erf;
     117: }

#### Defined functions

freebuf defined in line 75; used 14 times

- in /usr/ingres/source/decomp/decision.c line 114, 171, 212, 233
- in /usr/ingres/source/decomp/decomp.c line 217, 243
- in /usr/ingres/source/decomp/readq.c line 45
- in /usr/ingres/source/decomp/reformat.c line 281, 292
- in /usr/ingres/source/ovqp/getqry.c line 151
- in /usr/ingres/source/ovqp/interp.c line 90, 129-134(2), 153

markbuf defined in line 51; used 8 times

- in /usr/ingres/source/decomp/decision.c line 71, 189
- in /usr/ingres/source/decomp/decomp.c line 169, 184
- in /usr/ingres/source/decomp/readq.c line 42
- in /usr/ingres/source/decomp/reformat.c line 245
- in /usr/ingres/source/ovqp/getqry.c line 54
- in /usr/ingres/source/ovqp/interp.c line 70

seterr defined in line 105; used 1 times

- in /usr/ingres/source/ovqp/interp.c line 69

#### Defined struct's

nodbuffer defined in line 28; used 12 times

- in line 52-54(4), 76-79(4), 106-110(4)

Last modified: 1995-02-09 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 410 |