Commit bd9dd147 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Only set ptr to nil for Connect object when free'ing

The virXXXXFree() methods do not in fact return the remaining
reference count for the object - they always return 0. So we
cannot set 'ptr' to nil when calling Free() on a Go level object.

The virConnectClose() method, however, is an exception as it
returns 1 if references remain, 0 if no references remain.
So we should be setting 'ptr' to nil for the Connect object.
Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent aba6f064
......@@ -419,6 +419,7 @@ func (c *Connect) Close() (int, error) {
if result == 0 {
// No more reference to this connection, release data.
releaseConnectionData(c)
c.ptr = nil
}
return result, nil
}
......
......@@ -864,8 +864,6 @@ func (d *Domain) Free() error {
ret := C.virDomainFree(d.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
d.ptr = nil
}
return nil
}
......
......@@ -93,8 +93,6 @@ func (s *DomainSnapshot) Free() error {
ret := C.virDomainSnapshotFree(s.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
s.ptr = nil
}
return nil
}
......
......@@ -115,8 +115,6 @@ func (n *Interface) Free() error {
ret := C.virInterfaceFree(n.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
n.ptr = nil
}
return nil
}
......
......@@ -125,8 +125,6 @@ func (n *Network) Free() error {
ret := C.virNetworkFree(n.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
n.ptr = nil
}
return nil
}
......
......@@ -61,8 +61,6 @@ func (n *NodeDevice) Free() error {
ret := C.virNodeDeviceFree(n.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
n.ptr = nil
}
return nil
}
......
......@@ -46,8 +46,6 @@ func (f *NWFilter) Free() error {
ret := C.virNWFilterFree(f.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
f.ptr = nil
}
return nil
}
......
......@@ -71,8 +71,6 @@ func (s *Secret) Free() error {
ret := C.virSecretFree(s.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
s.ptr = nil
}
return nil
}
......
......@@ -139,8 +139,6 @@ func (p *StoragePool) Free() error {
ret := C.virStoragePoolFree(p.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
p.ptr = nil
}
return nil
}
......
......@@ -123,8 +123,6 @@ func (v *StorageVol) Free() error {
ret := C.virStorageVolFree(v.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
v.ptr = nil
}
return nil
}
......
......@@ -80,8 +80,6 @@ func (v *Stream) Free() error {
ret := C.virStreamFree(v.ptr)
if ret == -1 {
return GetLastError()
} else if ret == 0 {
v.ptr = nil
}
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment