Commit b1941884 authored by Daniel Salzman's avatar Daniel Salzman

qptrie: allow NULL trie_cb callback

parent 509e465a
......@@ -1246,9 +1246,11 @@ static void mark_cow(trie_cow_t *cow, node_t *t)
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);
}
}
}
......@@ -1376,8 +1378,10 @@ static void cow_cleanup(trie_cow_t *cow, node_t *t, trie_cb *cb, void *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;
......
......@@ -212,7 +212,7 @@ void trie_it_del(trie_it_t *it);
* 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
......@@ -253,6 +253,8 @@ int trie_del_cow(trie_cow_t *cow, const trie_key_t *key, uint32_t len, trie_val_
* 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);
......@@ -263,6 +265,8 @@ 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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment