+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;
+ }
+}
+
+/* Deletes 'node' from 'sh' and frees the node's name. The caller is still
+ * responsible for freeing the node's data, if necessary. */