+ return shash_add_nocopy__(sh, name, data, hash_name(name));
+}
+
+/* It is the caller's responsibility to avoid duplicate names, if that is
+ * desirable. */
+struct shash_node *
+shash_add(struct shash *sh, const char *name, const void *data)
+{
+ return shash_add_nocopy(sh, xstrdup(name), data);
+}
+
+bool
+shash_add_once(struct shash *sh, const char *name, const void *data)
+{
+ if (!shash_find(sh, name)) {
+ shash_add(sh, name, data);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void
+shash_add_assert(struct shash *sh, const char *name, const void *data)
+{
+ bool added OVS_UNUSED = shash_add_once(sh, name, data);
+ ovs_assert(added);
+}
+
+/* Searches for 'name' in 'sh'. If it does not already exist, adds it along
+ * with 'data' and returns NULL. If it does already exist, replaces its data
+ * by 'data' and returns the data that it formerly contained. */
+void *
+shash_replace(struct shash *sh, const char *name, const void *data)
+{
+ size_t hash = hash_name(name);
+ struct shash_node *node;
+
+ node = shash_find__(sh, name, strlen(name), hash);
+ if (!node) {
+ shash_add_nocopy__(sh, xstrdup(name), data, hash);
+ return NULL;
+ } else {
+ void *old_data = node->data;
+ node->data = CONST_CAST(void *, data);
+ return old_data;
+ }