hmap: Rename hmap_moved() to hmap_node_moved().
authorBen Pfaff <blp@nicira.com>
Thu, 28 Jan 2010 22:12:56 +0000 (14:12 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 29 Jan 2010 00:06:31 +0000 (16:06 -0800)
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.

lib/classifier.c
lib/hmap.c
lib/hmap.h

index 94c8380..f4280ef 100644 (file)
@@ -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);
         }
     }
 }
index f75fc07..d66cf27 100644 (file)
@@ -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;
+}
+
index c78ddda..9bb3e5f 100644 (file)
@@ -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