Commit fe9edbf6 authored by Libor Peltan's avatar Libor Peltan

journal: handling possible error state in changeset_to_contents

parent 5508a3c6
......@@ -498,19 +498,23 @@ int changeset_cancelout(changeset_t *change)
return ret;
}
zone_contents_t *changeset_to_contents(changeset_t *ch)
int changeset_to_contents(changeset_t *ch, zone_contents_t **out)
{
assert(ch->soa_from == NULL);
assert(zone_contents_is_empty(ch->remove));
assert(out != NULL);
zone_contents_t *res = ch->add;
add_rr_to_contents(res, ch->soa_to);
*out = ch->add;
int ret = add_rr_to_contents(*out, ch->soa_to);
knot_rrset_free(&ch->soa_to, NULL);
if (ret != KNOT_EOK) {
zone_contents_deep_free(out);
}
zone_contents_deep_free(&ch->remove);
free(ch->data);
free(ch);
return res;
return ret;
}
changeset_t *changeset_from_contents(const zone_contents_t *contents)
......
......@@ -158,10 +158,11 @@ int changeset_cancelout(changeset_t *change);
* \brief Loads zone contents from botstrap changeset.
*
* \param ch Changeset to load from, will be freed!
* \param out Zone contents.
*
* \return Zone contents.
* \return KNOT_E*
*/
zone_contents_t *changeset_to_contents(changeset_t *ch);
int changeset_to_contents(changeset_t *ch, zone_contents_t **out);
/*!
* \brief Creates a bootstrap changeset from zone.
......
......@@ -190,7 +190,11 @@ int zone_load_from_journal(conf_t *conf, zone_t *zone, zone_contents_t **content
changeset_t *boo_ch = (changeset_t *)HEAD(chgs);
rem_node(&boo_ch->n);
*contents = changeset_to_contents(boo_ch);
ret = changeset_to_contents(boo_ch, contents);
if (ret != KNOT_EOK) {
changesets_free(&chgs);
return ret;
}
apply_ctx_t a_ctx = { 0 };
apply_init_ctx(&a_ctx, *contents, 0);
......
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