FreeBSD/contrib/subversion/subversion/libsvn_subr/cache-membuffer.c
/* Insert ENTRY to the chain of items that belong to LEVEL in CACHE.  IDX
 * is ENTRY's item index and is only given for efficiency.  The insertion
 * takes place just before LEVEL->NEXT.  *CACHE will not be modified.
 */
Insert ENTRY to the chain of items that belong to LEVEL in CACHE.  IDX
is ENTRY's item index and is only given for efficiency.  The insertion
takes place just before LEVEL->NEXT.  *CACHE will not be modified.
Insert ENTRY to the chain of items that belong to LEVEL in CACHE . IDX is ENTRY ' s item index and is only given for efficiency . The insertion takes place just before LEVEL - > NEXT . * CACHE will not be modified .
static void
chain_entry(svn_membuffer_t *cache,
            cache_level_t *level,
            entry_t *entry,
            apr_uint32_t idx)
{
  entry_t *next = level->next == NO_INDEX
                ? NULL
                : get_entry(cache, level->next);
  assert(idx == get_index(cache, entry));
  entry->next = level->next;
  if (level->first == NO_INDEX)
    {
      entry->previous = NO_INDEX;
      level->last = idx;
      level->first = idx;
    }
  else if (next == NULL)
    {
      entry->previous = level->last;
      get_entry(cache, level->last)->next = idx;
      level->last = idx;
    }
  else
    {
      entry->previous = next->previous;
      next->previous = idx;
      if (entry->previous != NO_INDEX)
        get_entry(cache, entry->previous)->next = idx;
      else
        level->first = idx;
    }
}
static void chain_entry ( svn_membuffer_t * cache , cache_level_t * level , entry_t * entry , apr_uint32_t idx ) { entry_t * next = level -> next == NO_INDEX ? NULL : get_entry ( cache , level -> next ) ; assert ( idx == get_index ( cache , entry ) ) ; entry -> next = level -> next ; if ( level -> first == NO_INDEX ) { entry -> previous = NO_INDEX ; level -> last = idx ; level -> first = idx ; } else if ( next == NULL ) { entry -> previous = level -> last ; get_entry ( cache , level -> last ) -> next = idx ; level -> last = idx ; } else { entry -> previous = next -> previous ; next -> previous = idx ; if ( entry -> previous != NO_INDEX ) get_entry ( cache , entry -> previous ) -> next = idx ; else level -> first = idx ; } }
Insert ENTRY to the chain of items that belong to LEVEL in CACHE.
Insert ENTRY to the chain of items that belong to LEVEL in CACHE .
/* insert ENTRY before this item */ /* update entry chain
   */ /* insert as the first entry and only in the chain
       */ /* insert as the last entry in the chain.
       * Note that it cannot also be at the beginning of the chain.
       */ /* insert either at the start of a non-empty list or
       * somewhere in the middle
       */