lib/cmap.c
/* Replaces 'old_node' in 'cmap' with 'new_node'.  The caller must
 * ensure that 'cmap' cannot change concurrently (from another thread).
 *
 * 'old_node' must not be destroyed or modified or inserted back into 'cmap' or
 * into any other concurrent hash map while any other thread might be accessing
 * it.  One correct way to do this is to free it from an RCU callback with
 * ovsrcu_postpone().
 *
 * Returns the current number of nodes in the cmap after the replacement.  The
 * number of nodes decreases by one if 'new_node' is NULL. */


'old_node' must not be destroyed or modified or inserted back into 'cmap' or
into any other concurrent hash map while any other thread might be accessing
it.  One correct way to do this is to free it from an RCU callback with
ovsrcu_postpone().

Returns the current number of nodes in the cmap after the replacement.  The
number of nodes decreases by one if 'new_node' is NULL.
' old_node ' must not be destroyed or modified or inserted back into ' cmap ' or into any other concurrent hash map while any other thread might be accessing it . One correct way to do this is to free it from an RCU callback with ovsrcu_postpone () . Returns the current number of nodes in the cmap after the replacement . The number of nodes decreases by one if ' new_node ' is NULL .
size_t
cmap_replace(struct cmap *cmap, struct cmap_node *old_node,
             struct cmap_node *new_node, uint32_t hash)
{
    struct cmap_impl *impl = cmap_get_impl(cmap);
    uint32_t h1 = rehash(impl, hash);
    uint32_t h2 = other_hash(h1);
    ovs_assert(cmap_replace__(impl, old_node, new_node, hash, h1) ||
               cmap_replace__(impl, old_node, new_node, hash, h2));
    if (!new_node) {
        impl->n--;
        if (OVS_UNLIKELY(impl->n < impl->min_n)) {
            COVERAGE_INC(cmap_shrink);
            impl = cmap_rehash(cmap, impl->mask >> 1);
        }
    }
    return impl->n;
}
size_t cmap_replace ( struct cmap * cmap , struct cmap_node * old_node , struct cmap_node * new_node , uint32_t hash ) { struct cmap_impl * impl = cmap_get_impl ( cmap ) ; uint32_t h1 = rehash ( impl , hash ) ; uint32_t h2 = other_hash ( h1 ) ; ovs_assert ( cmap_replace__ ( impl , old_node , new_node , hash , h1 ) || cmap_replace__ ( impl , old_node , new_node , hash , h2 ) ) ; if ( ! new_node ) { impl -> n -- ; if ( OVS_UNLIKELY ( impl -> n < impl -> min_n ) ) { COVERAGE_INC ( cmap_shrink ) ; impl = cmap_rehash ( cmap , impl -> mask >> 1 ) ; } } return impl -> n ; }
Replaces 'old_node' in 'cmap' with 'new_node'.
Replaces ' old_node ' in ' cmap ' with ' new_node ' .