The ref count was assigned to 1 at creation, then never modified again
until it was decremented just before freeing the object.
* src/conf/domain_conf.h (_virDomainSnapshotObj): Delete unused
field.
(virDomainSnapshotObjUnref): Delete unused prototype.
* src/libvirt_private.syms: Likewise.
* src/conf/domain_conf.c (virDomainSnapshotObjNew)
(virDomainSnapshotObjListDataFree): Update users.
(virDomainSnapshotObjUnref): Delete.
---
I was about to add ATTRIBUTE_RETURN_CHECK to all Unref methods,
when I discovered that this method is (currently) worthless.
If we ever change things in the future to have multiple threads
referring to snapshot objects and need a reference counter, we
can use Wen's proposed new base-class object to do that in a
saner manner. In the meantime, let's just delete the bloat.
src/conf/domain_conf.c | 15 +--------------
src/conf/domain_conf.h | 3 ---
src/libvirt_private.syms | 1 -
3 files changed, 1 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c637300..1b02c25 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8722,8 +8722,6 @@ static virDomainSnapshotObjPtr virDomainSnapshotObjNew(void)
return NULL;
}
- snapshot->refs = 1;
-
VIR_DEBUG("obj=%p", snapshot);
return snapshot;
@@ -8740,17 +8738,6 @@ static void virDomainSnapshotObjFree(virDomainSnapshotObjPtr
snapshot)
VIR_FREE(snapshot);
}
-int virDomainSnapshotObjUnref(virDomainSnapshotObjPtr snapshot)
-{
- snapshot->refs--;
- VIR_DEBUG("obj=%p refs=%d", snapshot, snapshot->refs);
- if (snapshot->refs == 0) {
- virDomainSnapshotObjFree(snapshot);
- return 0;
- }
- return snapshot->refs;
-}
-
virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr
snapshots,
const virDomainSnapshotDefPtr def)
{
@@ -8782,7 +8769,7 @@ virDomainSnapshotObjListDataFree(void *payload,
{
virDomainSnapshotObjPtr obj = payload;
- virDomainSnapshotObjUnref(obj);
+ virDomainSnapshotObjFree(obj);
}
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cbd0f98..9f595d6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -998,8 +998,6 @@ struct _virDomainSnapshotDef {
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
struct _virDomainSnapshotObj {
- int refs;
-
virDomainSnapshotDefPtr def;
};
@@ -1028,7 +1026,6 @@ virDomainSnapshotObjPtr virDomainSnapshotFindByName(const
virDomainSnapshotObjLi
const char *name);
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotObjPtr snapshot);
-int virDomainSnapshotObjUnref(virDomainSnapshotObjPtr snapshot);
int virDomainSnapshotHasChildren(virDomainSnapshotObjPtr snap,
virDomainSnapshotObjListPtr snapshots);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 55be36e..b4b6c63 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -305,7 +305,6 @@ virDomainSnapshotHasChildren;
virDomainSnapshotObjListGetNames;
virDomainSnapshotObjListNum;
virDomainSnapshotObjListRemove;
-virDomainSnapshotObjUnref;
virDomainSoundDefFree;
virDomainSoundModelTypeFromString;
virDomainSoundModelTypeToString;
--
1.7.4