mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virlog: Introduce virLogOutputFree
Provide a separate method to free a logging output object. This will come handy once a method to create an individual logging output object is introduced. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
51b2606fec
commit
057788c537
@ -1822,6 +1822,7 @@ virLogGetNbOutputs;
|
||||
virLogGetOutputs;
|
||||
virLogLock;
|
||||
virLogMessage;
|
||||
virLogOutputFree;
|
||||
virLogParseDefaultPriority;
|
||||
virLogParseFilters;
|
||||
virLogParseOutputs;
|
||||
|
@ -106,8 +106,6 @@ struct _virLogOutput {
|
||||
virLogDestination dest;
|
||||
char *name;
|
||||
};
|
||||
typedef struct _virLogOutput virLogOutput;
|
||||
typedef virLogOutput *virLogOutputPtr;
|
||||
|
||||
static virLogOutputPtr *virLogOutputs;
|
||||
static size_t virLogNbOutputs;
|
||||
@ -329,17 +327,27 @@ virLogResetOutputs(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < virLogNbOutputs; i++) {
|
||||
if (virLogOutputs[i]->c != NULL)
|
||||
virLogOutputs[i]->c(virLogOutputs[i]->data);
|
||||
VIR_FREE(virLogOutputs[i]->name);
|
||||
VIR_FREE(virLogOutputs[i]);
|
||||
}
|
||||
for (i = 0; i < virLogNbOutputs; i++)
|
||||
virLogOutputFree(virLogOutputs[i]);
|
||||
|
||||
VIR_FREE(virLogOutputs);
|
||||
virLogNbOutputs = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virLogOutputFree(virLogOutputPtr output)
|
||||
{
|
||||
if (!output)
|
||||
return;
|
||||
|
||||
if (output->c)
|
||||
output->c(output->data);
|
||||
VIR_FREE(output->name);
|
||||
VIR_FREE(output);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* virLogDefineOutput:
|
||||
* @f: the function to call to output a message
|
||||
|
@ -130,6 +130,9 @@ struct _virLogMetadata {
|
||||
typedef struct _virLogMetadata virLogMetadata;
|
||||
typedef struct _virLogMetadata *virLogMetadataPtr;
|
||||
|
||||
typedef struct _virLogOutput virLogOutput;
|
||||
typedef virLogOutput *virLogOutputPtr;
|
||||
|
||||
/**
|
||||
* virLogOutputFunc:
|
||||
* @src: the source of the log message
|
||||
@ -187,6 +190,7 @@ int virLogDefineOutput(virLogOutputFunc f,
|
||||
virLogDestination dest,
|
||||
const char *name,
|
||||
unsigned int flags);
|
||||
void virLogOutputFree(virLogOutputPtr output);
|
||||
|
||||
/*
|
||||
* Internal logging API
|
||||
|
Loading…
Reference in New Issue
Block a user