FreeBSD/contrib/subversion/subversion/libsvn_fs_x/index.c
/* Run-length-encode the uint64 numbers in ARRAY starting at index START
 * up to but not including END.  All numbers must be > 0.
 * Return the number of remaining entries in ARRAY after START.
 */
Run-length-encode the uint64 numbers in ARRAY starting at index START
up to but not including END.  All numbers must be > 0.
Return the number of remaining entries in ARRAY after START.
Run - length - encode the uint64 numbers in ARRAY starting at index START up to but not including END . All numbers must be > 0 . Return the number of remaining entries in ARRAY after START .
static int
rle_array(apr_array_header_t *array, int start, int end)
{
  int i;
  int target = start;
  for (i = start; i < end; ++i)
    {
      apr_uint64_t value = APR_ARRAY_IDX(array, i, apr_uint64_t);
      assert(value > 0);
      if (value == 1)
        {
          int counter;
          for (counter = 1; i + counter < end; ++counter)
            if (APR_ARRAY_IDX(array, i + counter, apr_uint64_t) != 1)
              break;
          if (--counter)
            {
              APR_ARRAY_IDX(array, target, apr_uint64_t) = 0;
              APR_ARRAY_IDX(array, target + 1, apr_uint64_t) = counter;
              target += 2;
              i += counter;
              continue;
            }
        }
      APR_ARRAY_IDX(array, target, apr_uint64_t) = value;
      ++target;
    }
  return target;
}
static int rle_array ( apr_array_header_t * array , int start , int end ) { int i ; int target = start ; for ( i = start ; i < end ; ++ i ) { apr_uint64_t value = APR_ARRAY_IDX ( array , i , apr_uint64_t ) ; assert ( value > 0 ) ; if ( value == 1 ) { int counter ; for ( counter = 1 ; i + counter < end ; ++ counter ) if ( APR_ARRAY_IDX ( array , i + counter , apr_uint64_t ) != 1 ) break ; if ( -- counter ) { APR_ARRAY_IDX ( array , target , apr_uint64_t ) = 0 ; APR_ARRAY_IDX ( array , target + 1 , apr_uint64_t ) = counter ; target += 2 ; i += counter ; continue ; } } APR_ARRAY_IDX ( array , target , apr_uint64_t ) = value ; ++ target ; } return target ; }
Run-length-encode the uint64 numbers in ARRAY starting at index START
 up to but not including END.
Run - length - encode the uint64 numbers in ARRAY starting at index START up to but not including END .