---
src/datatypes.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index e115a23..1b95b21 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -161,6 +161,18 @@ virConnectDispose(void *obj)
}
+static
+void virConnectCloseCallbackDataReset(virConnectCloseCallbackDataPtr close)
+{
+ if (close->freeCallback)
+ close->freeCallback(close->opaque);
+
+ close->freeCallback = NULL;
+ close->opaque = NULL;
+ virObjectUnref(close->conn);
+ close->conn = NULL;
+}
+
/**
* virConnectCloseCallbackDataDispose:
* @obj: the close callback data to release
@@ -174,9 +186,7 @@ virConnectCloseCallbackDataDispose(void *obj)
virObjectLock(cb);
- if (cb->freeCallback)
- cb->freeCallback(cb->opaque);
- virObjectUnref(cb->conn);
+ virConnectCloseCallbackDataReset(cb);
virObjectUnlock(cb);
}
@@ -218,12 +228,8 @@ void
virConnectCloseCallbackDataUnregister(virConnectCloseCallbackDataPtr close,
goto cleanup;
}
+ virConnectCloseCallbackDataReset(close);
close->callback = NULL;
- if (close->freeCallback)
- close->freeCallback(close->opaque);
- close->freeCallback = NULL;
- virObjectUnref(close->conn);
- close->conn = NULL;
cleanup:
@@ -242,11 +248,7 @@ void virConnectCloseCallbackDataCall(virConnectCloseCallbackDataPtr
close,
close->callback, reason, close->opaque);
close->callback(close->conn, reason, close->opaque);
- if (close->freeCallback)
- close->freeCallback(close->opaque);
- close->freeCallback = NULL;
- virObjectUnref(close->conn);
- close->conn = NULL;
+ virConnectCloseCallbackDataReset(close);
exit:
virObjectUnlock(close);
--
1.8.3.1