object->i |= TFLAG_COW;
} else {
tkey_t *lkey = tkey(t);
- trie_val_t *valp = tvalp(t);
lkey->cow = 1;
- cow->mark_shared(*valp, lkey->chars, lkey->len, cow->d);
+ if (cow->mark_shared != NULL) {
+ trie_val_t *valp = tvalp(t);
+ cow->mark_shared(*valp, lkey->chars, lkey->len, cow->d);
+ }
}
}
} else {
// application must decide how to clean up its values
tkey_t *lkey = tkey(t);
- trie_val_t *valp = tvalp(t);
- cb(*valp, lkey->chars, lkey->len, d);
+ if (cb != NULL) {
+ trie_val_t *valp = tvalp(t);
+ cb(*valp, lkey->chars, lkey->len, d);
+ }
// clean up exclusively-owned keys
if (lkey->cow)
lkey->cow = 0;
* There must be only one write transaction at a time.
*
* \param old the old trie
- * \param mark_shared callback to mark a leaf as shared
+ * \param mark_shared callback to mark a leaf as shared (can be NULL)
* \param d extra data for the callback
* \return a pointer to a COW context,
* or NULL if there was a failure
* cleaning up; you must free any objects you have marked as old-only
* and retain objects with shared reachability.
*
+ * \note The callback can be NULL.
+ *
* The cow object is free()d, and the new trie root is returned.
*/
trie_t* trie_cow_commit(trie_cow_t *cow, trie_cb *cb, void *d);
* cleaning up; you must free any objects you have marked as new-only
* and retain objects with shared reachability.
*
+ * \note The callback can be NULL.
+ *
* The cow object is free()d, and the old trie root is returned.
*/
trie_t* trie_cow_rollback(trie_cow_t *cow, trie_cb *cb, void *d);