---
src/datatypes.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index 73c7e7e..57162ec 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -161,6 +161,19 @@ virConnectDispose(void *obj)
}
+static
+void virConnectCloseCallbackDataReset(virConnectCloseCallbackDataPtr close)
+{
+ if (close->freeCallback)
+ close->freeCallback(close->opaque);
+
+ close->freeCallback = NULL;
+ close->callback = NULL;
+ close->opaque = NULL;
+ virObjectUnref(close->conn);
+ close->conn = NULL;
+}
+
/**
* virConnectCloseCallbackDataDispose:
* @obj: the close callback data to release
@@ -174,9 +187,7 @@ virConnectCloseCallbackDataDispose(void *obj)
virObjectLock(cb);
- if (cb->freeCallback)
- cb->freeCallback(cb->opaque);
- virObjectUnref(cb->conn);
+ virConnectCloseCallbackDataReset(cb);
virObjectUnlock(cb);
}
@@ -223,12 +234,7 @@ int
virConnectCloseCallbackDataUnregister(virConnectCloseCallbackDataPtr close,
goto error;
}
- close->callback = NULL;
- if (close->freeCallback)
- close->freeCallback(close->opaque);
- close->freeCallback = NULL;
- virObjectUnref(close->conn);
- close->conn = NULL;
+ virConnectCloseCallbackDataReset(close);
ret = 0;
@@ -249,12 +255,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->callback = NULL;
- close->freeCallback = NULL;
- virObjectUnref(close->conn);
- close->conn = NULL;
+ virConnectCloseCallbackDataReset(close);
exit:
virObjectUnlock(close);
--
1.8.3.1