virsysinfo: Define and use auto cleanup func for virSysinfoDef properly

What we are using really is heap allocated structure rather than
stack allocated. And for that it's better to use g_autoptr() +
G_DEFINE_AUTOPTR_CLEANUP_FUNC() combo, as Glib documentation for
g_auto() reads:

  This is meant to be used with stack-allocated structures and
  non-pointer types. For the (more commonly used) pointer
  version, see g_autoptr().

This will be even more visible, when virSysinfoDefPtr type is
gone. Stay tuned.

Fixes: cee3a900a0
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik
2021-03-11 06:17:07 +01:00
parent 52a937d8a2
commit ab9afee6e7
3 changed files with 6 additions and 6 deletions

View File

@@ -91,7 +91,7 @@ testSysinfo(const void *data)
{
const struct testSysinfoData *testdata = data;
const char *sysfsActualData;
g_auto(virSysinfoDefPtr) ret = NULL;
g_autoptr(virSysinfoDef) ret = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *sysinfo = NULL;
g_autofree char *cpuinfo = NULL;