mirror of
https://github.com/openvswitch/ovs
synced 2025-10-11 13:57:52 +00:00
hmap: Rename hmap_moved() to hmap_node_moved().
This prepares for adding a new function that deals with a "struct hmap" moving, as opposed to a "struct hmap_node". Since there was only a single call to this in the whole tree, and its caller didn't have any callers of its own at all, also move this function from hmap.h to hmap.c.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Nicira Networks.
|
||||
* Copyright (c) 2009, 2010 Nicira Networks.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -102,7 +102,8 @@ cls_rule_moved(struct classifier *cls, struct cls_rule *old,
|
||||
if (new->wc.wildcards) {
|
||||
list_moved(&new->node.list);
|
||||
} else {
|
||||
hmap_moved(&cls->exact_table, &old->node.hmap, &new->node.hmap);
|
||||
hmap_node_moved(&cls->exact_table,
|
||||
&old->node.hmap, &new->node.hmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
lib/hmap.c
16
lib/hmap.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2009 Nicira Networks.
|
||||
* Copyright (c) 2008, 2009, 2010 Nicira Networks.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -143,3 +143,17 @@ hmap_reserve(struct hmap *hmap, size_t n)
|
||||
resize(hmap, new_mask);
|
||||
}
|
||||
}
|
||||
|
||||
/* Adjusts 'hmap' to compensate for 'old_node' having moved position in memory
|
||||
* to 'node' (e.g. due to realloc()). */
|
||||
void
|
||||
hmap_node_moved(struct hmap *hmap,
|
||||
struct hmap_node *old_node, struct hmap_node *node)
|
||||
{
|
||||
struct hmap_node **bucket = &hmap->buckets[node->hash & hmap->mask];
|
||||
while (*bucket != old_node) {
|
||||
bucket = &(*bucket)->next;
|
||||
}
|
||||
*bucket = node;
|
||||
}
|
||||
|
||||
|
18
lib/hmap.h
18
lib/hmap.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2009 Nicira Networks.
|
||||
* Copyright (c) 2008, 2009, 2010 Nicira Networks.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,8 +79,7 @@ static inline void hmap_insert_fast(struct hmap *,
|
||||
struct hmap_node *, size_t hash);
|
||||
static inline void hmap_insert(struct hmap *, struct hmap_node *, size_t hash);
|
||||
static inline void hmap_remove(struct hmap *, struct hmap_node *);
|
||||
static inline void hmap_moved(struct hmap *,
|
||||
struct hmap_node *, struct hmap_node *);
|
||||
void hmap_node_moved(struct hmap *, struct hmap_node *, struct hmap_node *);
|
||||
static inline void hmap_replace(struct hmap *, const struct hmap_node *old,
|
||||
struct hmap_node *new);
|
||||
|
||||
@@ -207,19 +206,6 @@ hmap_remove(struct hmap *hmap, struct hmap_node *node)
|
||||
hmap->n--;
|
||||
}
|
||||
|
||||
/* Adjusts 'hmap' to compensate for 'old_node' having moved position in memory
|
||||
* to 'node' (e.g. due to realloc()). */
|
||||
static inline void
|
||||
hmap_moved(struct hmap *hmap,
|
||||
struct hmap_node *old_node, struct hmap_node *node)
|
||||
{
|
||||
struct hmap_node **bucket = &hmap->buckets[node->hash & hmap->mask];
|
||||
while (*bucket != old_node) {
|
||||
bucket = &(*bucket)->next;
|
||||
}
|
||||
*bucket = node;
|
||||
}
|
||||
|
||||
/* Puts 'new' in the position in 'hmap' currently occupied by 'old'. The 'new'
|
||||
* node must hash to the same value as 'old'. The client is responsible for
|
||||
* ensuring that the replacement does not violate any client-imposed
|
||||
|
Reference in New Issue
Block a user