Eo: Better handle object cleanup on failure.

While unrefing twice works, it's cleaner to unref the ref we
have and delete normally. It will handle parnet detachments in
a nicer way, and is just more correct.
This commit is contained in:
Tom Hacohen 2015-05-20 16:48:20 +01:00
parent a22ac701b6
commit c02bab4149
1 changed files with 2 additions and 4 deletions

View File

@ -926,9 +926,8 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo
{
ERR("Object of class '%s' - Error while constructing object",
klass->desc->name);
/* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */
_eo_unref(obj);
_eo_unref(obj);
eo_del((Eo *) obj->header.id);
return NULL;
}
@ -981,9 +980,8 @@ _eo_add_internal_end(Eo *eo_id)
return (Eo *)eo_id;
cleanup:
/* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */
_eo_unref(fptr->o.obj);
_eo_unref(fptr->o.obj);
eo_del((Eo *) fptr->o.obj->header.id);
return NULL;
}