mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
util: Allow virFileCache data to be any GObject
Since the libvirt documentation suggests to prefer GObject over virObject, and since virObject is a GObject, change virFileCache to allow GObjects as data. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
03afd10cd3
commit
b7e7ac14d0
@ -170,7 +170,7 @@ virFileCacheLoad(virFileCache *cache,
|
||||
*data = g_steal_pointer(&loadData);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(loadData);
|
||||
g_clear_pointer(&loadData, g_object_unref);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ virFileCacheNewData(virFileCache *cache,
|
||||
return NULL;
|
||||
|
||||
if (virFileCacheSave(cache, name, data) < 0) {
|
||||
g_clear_pointer(&data, virObjectUnref);
|
||||
g_clear_object(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ virFileCacheNew(const char *dir,
|
||||
if (!(cache = virObjectNew(virFileCacheClass)))
|
||||
return NULL;
|
||||
|
||||
cache->table = virHashNew(virObjectUnref);
|
||||
cache->table = virHashNew(g_object_unref);
|
||||
|
||||
cache->dir = g_strdup(dir);
|
||||
|
||||
@ -270,7 +270,7 @@ virFileCacheValidate(virFileCache *cache,
|
||||
if (*data) {
|
||||
VIR_DEBUG("Caching data '%p' for '%s'", *data, name);
|
||||
if (virHashAddEntry(cache->table, name, *data) < 0) {
|
||||
g_clear_pointer(data, virObjectUnref);
|
||||
g_clear_pointer(data, g_object_unref);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,8 @@ virFileCacheLookup(virFileCache *cache,
|
||||
data = virHashLookup(cache->table, name);
|
||||
virFileCacheValidate(cache, name, &data);
|
||||
|
||||
virObjectRef(data);
|
||||
if (data)
|
||||
g_object_ref(data);
|
||||
virObjectUnlock(cache);
|
||||
|
||||
return data;
|
||||
@ -331,7 +332,8 @@ virFileCacheLookupByFunc(virFileCache *cache,
|
||||
data = virHashSearch(cache->table, iter, iterData, &name);
|
||||
virFileCacheValidate(cache, name, &data);
|
||||
|
||||
virObjectRef(data);
|
||||
if (data)
|
||||
g_object_ref(data);
|
||||
virObjectUnlock(cache);
|
||||
|
||||
return data;
|
||||
|
@ -48,7 +48,7 @@ typedef bool
|
||||
* @priv: private data created together with cache
|
||||
*
|
||||
* Creates a new data based on the @name. The returned data must be
|
||||
* an instance of virObject.
|
||||
* an instance of GObject.
|
||||
*
|
||||
* Returns data object or NULL on error.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user