util: Use glib memory functions in virLogFilterNew
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
38f7fdfdb4
commit
51b97132b1
@ -1308,7 +1308,6 @@ virLogFilterNew(const char *match,
|
|||||||
virLogPriority priority)
|
virLogPriority priority)
|
||||||
{
|
{
|
||||||
virLogFilterPtr ret = NULL;
|
virLogFilterPtr ret = NULL;
|
||||||
char *mdup = NULL;
|
|
||||||
size_t mlen = strlen(match);
|
size_t mlen = strlen(match);
|
||||||
|
|
||||||
if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
|
if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
|
||||||
@ -1317,23 +1316,16 @@ virLogFilterNew(const char *match,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = g_new0(virLogFilter, 1);
|
||||||
|
ret->priority = priority;
|
||||||
|
|
||||||
/* We must treat 'foo' as equiv to '*foo*' for g_pattern_match
|
/* We must treat 'foo' as equiv to '*foo*' for g_pattern_match
|
||||||
* todo substring matches, so add 2 extra bytes
|
* todo substring matches, so add 2 extra bytes
|
||||||
*/
|
*/
|
||||||
if (VIR_ALLOC_N_QUIET(mdup, mlen + 3) < 0)
|
ret->match = g_new0(char, mlen + 3);
|
||||||
return NULL;
|
ret->match[0] = '*';
|
||||||
|
memcpy(ret->match + 1, match, mlen);
|
||||||
mdup[0] = '*';
|
ret->match[mlen + 1] = '*';
|
||||||
memcpy(mdup + 1, match, mlen);
|
|
||||||
mdup[mlen + 1] = '*';
|
|
||||||
|
|
||||||
if (VIR_ALLOC_QUIET(ret) < 0) {
|
|
||||||
VIR_FREE(mdup);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->match = mdup;
|
|
||||||
ret->priority = priority;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user