diff options
author | Tom Hacohen <tom@stosb.com> | 2015-05-20 16:48:20 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2015-05-20 16:48:33 +0100 |
commit | c02bab4149b2f3984d0f7a0637003d2bcd62fabd (patch) | |
tree | 8f6ef9bd1939db32611d2a888bd5b56fb58d8a96 | |
parent | a22ac701b6b705d07327ace41e9a05398ff3a466 (diff) |
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.
-rw-r--r-- | src/lib/eo/eo.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index dffdcdb639..766b7d3cb8 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c | |||
@@ -926,9 +926,8 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo | |||
926 | { | 926 | { |
927 | ERR("Object of class '%s' - Error while constructing object", | 927 | ERR("Object of class '%s' - Error while constructing object", |
928 | klass->desc->name); | 928 | klass->desc->name); |
929 | /* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */ | ||
930 | _eo_unref(obj); | ||
931 | _eo_unref(obj); | 929 | _eo_unref(obj); |
930 | eo_del((Eo *) obj->header.id); | ||
932 | return NULL; | 931 | return NULL; |
933 | } | 932 | } |
934 | 933 | ||
@@ -981,9 +980,8 @@ _eo_add_internal_end(Eo *eo_id) | |||
981 | return (Eo *)eo_id; | 980 | return (Eo *)eo_id; |
982 | 981 | ||
983 | cleanup: | 982 | cleanup: |
984 | /* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */ | ||
985 | _eo_unref(fptr->o.obj); | ||
986 | _eo_unref(fptr->o.obj); | 983 | _eo_unref(fptr->o.obj); |
984 | eo_del((Eo *) fptr->o.obj->header.id); | ||
987 | return NULL; | 985 | return NULL; |
988 | } | 986 | } |
989 | 987 | ||