return 0;
}
-void hashmap_move(Hashmap *h, Hashmap *other) {
+int hashmap_move(Hashmap *h, Hashmap *other) {
struct hashmap_entry *e, *n;
assert(h);
/* The same as hashmap_merge(), but every new item from other
- * is moved to h. This function is guaranteed to succeed. */
+ * is moved to h. */
if (!other)
- return;
+ return 0;
for (e = other->iterate_list_head; e; e = n) {
unsigned h_hash, other_hash;
unlink_entry(other, e, other_hash);
link_entry(h, e, h_hash);
}
+
+ return 0;
}
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
static inline int ordered_hashmap_reserve(OrderedHashmap *h, unsigned entries_add) {
return hashmap_reserve((Hashmap*) h, entries_add);
}
-void hashmap_move(Hashmap *h, Hashmap *other);
-static inline void ordered_hashmap_move(OrderedHashmap *h, OrderedHashmap *other) {
- hashmap_move((Hashmap*) h, (Hashmap*) other);
+int hashmap_move(Hashmap *h, Hashmap *other);
+static inline int ordered_hashmap_move(OrderedHashmap *h, OrderedHashmap *other) {
+ return hashmap_move((Hashmap*) h, (Hashmap*) other);
}
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
static inline int ordered_hashmap_move_one(OrderedHashmap *h, OrderedHashmap *other, const void *key) {
return hashmap_reserve(MAKE_HASHMAP(s), entries_add);
}
-void set_move(Set *s, Set *other) {
+int set_move(Set *s, Set *other) {
return hashmap_move(MAKE_HASHMAP(s), MAKE_HASHMAP(other));
}
int set_merge(Set *s, Set *other);
int set_reserve(Set *s, unsigned entries_add);
-void set_move(Set *s, Set *other);
+int set_move(Set *s, Set *other);
int set_move_one(Set *s, Set *other, void *value);
unsigned set_size(Set *s);
hashmap_put(m, "key 3", val3);
hashmap_put(m, "key 4", val4);
- hashmap_move(n, NULL);
- hashmap_move(n, m);
+ assert(hashmap_move(n, NULL) == 0);
+ assert(hashmap_move(n, m) == 0);
assert_se(hashmap_size(m) == 1);
r = hashmap_get(m, "key 1");