Ejemplo n.º 1
0
/*
 * Return the number of CONSECUTIVE bytes available for consuming.
 * However, don't return more than enough to cross over set mark.
 */
int
ring_full_consecutive (Ring * ring)
{
  if ((ring->mark == 0) || (ring->mark == ring->consume))
    {
      if ((ring->supply < ring->consume) || ring_full (ring))
	{
	  return ring_subtract (ring, ring->top, ring->consume);
	}
      else
	{
	  return ring_subtract (ring, ring->supply, ring->consume);
	}
    }
  else
    {
      if (ring->mark < ring->consume)
	{
	  return ring_subtract (ring, ring->top, ring->consume);
	}
      else
	{			/* Else, distance to mark */
	  return ring_subtract (ring, ring->mark, ring->consume);
	}
    }
}
Ejemplo n.º 2
0
int
ring_full_count(Ring *ring)
{
    if ((ring->mark == 0) || (ring->mark == ring->consume)) {
        if (ring_full(ring)) {
            return ring->size;	/* nothing consumed, but full */
        } else {
            return ring_subtract(ring, ring->supply, ring->consume);
        }
    } else {
        return ring_subtract(ring, ring->mark, ring->consume);
    }
}
Ejemplo n.º 3
0
/*
 * We have just consumed "c" bytes.
 */
void
ring_consumed (Ring * ring, int count)
{
  if (count == 0)		/* don't update anything */
    return;

  if (ring->mark && (ring_subtract (ring, ring->mark, ring->consume) < count))
    {
      ring->mark = 0;
    }
#ifdef	ENCRYPTION
  if (ring->consume < ring->clearto && ring->clearto <= ring->consume + count)
    ring->clearto = 0;
  else if (ring->consume + count > ring->top &&
	   ring->bottom <= ring->clearto &&
	   ring->bottom + ((ring->consume + count) - ring->top))
    ring->clearto = 0;
#endif /* ENCRYPTION */
  ring->consume = ring_increment (ring, ring->consume, count);
  ring->consumetime = ++ring_clock;
  /*
   * Try to encourage "ring_empty_consecutive()" to be large.
   */
  if (ring_empty (ring))
    {
      ring->consume = ring->supply = ring->bottom;
    }
}
Ejemplo n.º 4
0
/* number of CONSECUTIVE bytes that may be supplied */
int
ring_empty_consecutive(Ring *ring)
{
    if ((ring->consume < ring->supply) || ring_empty(ring)) {
        /*
         * if consume is "below" supply, or empty, then
         * return distance to the top
         */
        return ring_subtract(ring, ring->top, ring->supply);
    } else {
        /*
         * else, return what we may.
         */
        return ring_subtract(ring, ring->consume, ring->supply);
    }
}
Ejemplo n.º 5
0
/* Number of bytes that may be supplied */
int
ring_empty_count(Ring *ring)
{
    if (ring_empty(ring)) {	/* if empty */
        return ring->size;
    } else {
        return ring_subtract(ring, ring->consume, ring->supply);
    }
}