mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
libxlLoggerNew: Avoid virHashFree by rearranging code
Allocate the hash table only after the log file is opened so that we don't need to deallocate it on failure. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
35ebb28f3f
commit
04bbaa2b1f
@ -149,14 +149,13 @@ libxlLoggerNew(const char *logDir, virLogPriority minLevel)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
logger.logDir = logDir;
|
logger.logDir = logDir;
|
||||||
logger.files = virHashNew(libxlLoggerFileFree);
|
|
||||||
|
|
||||||
path = g_strdup_printf("%s/libxl-driver.log", logDir);
|
path = g_strdup_printf("%s/libxl-driver.log", logDir);
|
||||||
|
|
||||||
if ((logger.defaultLogFile = fopen(path, "a")) == NULL) {
|
if ((logger.defaultLogFile = fopen(path, "a")) == NULL)
|
||||||
virHashFree(logger.files);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
logger.files = virHashNew(libxlLoggerFileFree);
|
||||||
|
|
||||||
return XTL_NEW_LOGGER(libvirt, logger);
|
return XTL_NEW_LOGGER(libvirt, logger);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user