FreeBSD/contrib/subversion/subversion/libsvn_subr/cache-membuffer.c
/* Remove the used ENTRY from the CACHE, i.e. make it "unused".
 * In contrast to insertion, removal is possible for any entry.
 */
Remove the used ENTRY from the CACHE, i.e. make it "unused".
In contrast to insertion, removal is possible for any entry.
Remove the used ENTRY from the CACHE i . e . make it " unused " . In contrast to insertion removal is possible for any entry .
static void
drop_entry(svn_membuffer_t *cache, entry_t *entry)
{
  apr_uint32_t idx = get_index(cache, entry);
  apr_uint32_t group_index = idx / GROUP_SIZE;
  entry_group_t *last_group
    = last_group_in_chain(cache, &cache->directory[group_index]);
  apr_uint32_t last_in_group
    = (apr_uint32_t) ((last_group - cache->directory) * GROUP_SIZE
    + last_group->header.used - 1);
  cache_level_t *level = get_cache_level(cache, entry);
  cache->used_entries--;
  cache->data_used -= entry->size;
  if (idx == level->next)
    level->next = entry->next;
  else
    if (entry->next == level->next)
      {
        if (entry->previous == NO_INDEX)
          {
            level->current_data = level->start_offset;
          }
        else
          {
            entry_t *previous = get_entry(cache, entry->previous);
            level->current_data = ALIGN_VALUE(  previous->offset
                                              + previous->size);
          }
      }
  unchain_entry(cache, level, entry, idx);
  if (idx != last_in_group)
    {
      *entry = last_group->entries[last_group->header.used-1];
      level = get_cache_level(cache, entry);
      if (last_in_group == level->next)
        level->next = idx;
      if (entry->previous == NO_INDEX)
        level->first = idx;
      else
        get_entry(cache, entry->previous)->next = idx;
      if (entry->next == NO_INDEX)
        level->last = idx;
      else
        get_entry(cache, entry->next)->previous = idx;
    }
  last_group->header.used--;
  if (!last_group->header.used && last_group->header.previous != NO_INDEX)
    free_spare_group(cache, last_group);
}
static void drop_entry ( svn_membuffer_t * cache , entry_t * entry ) { apr_uint32_t idx = get_index ( cache , entry ) ; apr_uint32_t group_index = idx / GROUP_SIZE ; entry_group_t * last_group = last_group_in_chain ( cache , & cache -> directory [ group_index ] ) ; apr_uint32_t last_in_group = ( apr_uint32_t ) ( ( last_group - cache -> directory ) * GROUP_SIZE + last_group -> header . used - 1 ) ; cache_level_t * level = get_cache_level ( cache , entry ) ; cache -> used_entries -- ; cache -> data_used -= entry -> size ; if ( idx == level -> next ) level -> next = entry -> next ; else if ( entry -> next == level -> next ) { if ( entry -> previous == NO_INDEX ) { level -> current_data = level -> start_offset ; } else { entry_t * previous = get_entry ( cache , entry -> previous ) ; level -> current_data = ALIGN_VALUE ( previous -> offset + previous -> size ) ; } } unchain_entry ( cache , level , entry , idx ) ; if ( idx != last_in_group ) { * entry = last_group -> entries [ last_group -> header . used - 1 ] ; level = get_cache_level ( cache , entry ) ; if ( last_in_group == level -> next ) level -> next = idx ; if ( entry -> previous == NO_INDEX ) level -> first = idx ; else get_entry ( cache , entry -> previous ) -> next = idx ; if ( entry -> next == NO_INDEX ) level -> last = idx ; else get_entry ( cache , entry -> next ) -> previous = idx ; } last_group -> header . used -- ; if ( ! last_group -> header . used && last_group -> header . previous != NO_INDEX ) free_spare_group ( cache , last_group ) ; }
Remove the used ENTRY from the CACHE, i.e.
Remove the used ENTRY from the CACHE i . e .
/* the group that ENTRY belongs to plus a number of useful index values
   */ /* update global cache usage counters
   */ /* extend the insertion window, if the entry happens to border it
   */ /* insertion window starts right behind the entry to remove
         */ /* remove the first entry -> insertion may start at pos 0, now */ /* insertion may start right behind the previous entry */ /* unlink it from the chain of used entries
   */ /* Move last entry into hole (if the removed one is not the last used).
   * We need to do this since all used entries are at the beginning of
   * the group's entries array.
   */ /* copy the last used entry to the removed entry's index
       */ /* this ENTRY may belong to a different cache level than the entry
       * we have just removed */ /* update foreign links to new index
       */ /* Update the number of used entries.
   */ /* Release the last group in the chain if it is a spare group
   */