MINOR: log: add free_logformat_node() helper function

Function may be used to free a single logformat node.
This commit is contained in:
Aurelien DARRAGON 2024-02-22 15:03:29 +01:00
parent 62121d5b90
commit 1c2e16ba8a
2 changed files with 15 additions and 4 deletions

View File

@ -66,6 +66,7 @@ void deinit_log_buffers(void);
/* Deinitialize log buffers used for syslog messages */
void free_logformat_list(struct list *fmt);
void free_logformat_node(struct logformat_node *node);
/* build a log line for the session and an optional stream */
int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format);

View File

@ -2660,6 +2660,19 @@ void deinit_log_forward()
}
}
/* Releases memory for a single log-format node */
void free_logformat_node(struct logformat_node *node)
{
if (!node)
return;
release_sample_expr(node->expr);
node->expr = NULL;
ha_free(&node->name);
ha_free(&node->arg);
ha_free(&node);
}
/* Releases memory allocated for a log-format string */
void free_logformat_list(struct list *fmt)
{
@ -2670,10 +2683,7 @@ void free_logformat_list(struct list *fmt)
list_for_each_entry_safe(lf, lfb, fmt, list) {
LIST_DELETE(&lf->list);
release_sample_expr(lf->expr);
free(lf->name);
free(lf->arg);
free(lf);
free_logformat_node(lf);
}
}