template() and template_escape() extension for all destination drivers
Hi, On Wed, Oct 30, 2002 at 20:47:55+0100, Balazs Scheidler wrote:
I came to having some time to integrate pending patches, and found your patch. I have a couple of comments, which needs to be fixed before releasing a syslog-ng with these parts integrated.
* expand_macro & friends should be declared in a header file instead of declaring it in every referencing module. maybe a new file called macros.c would be a good way of resolving this problem.
* expand_macros returns a newly allocated string, which must be freed, so constructs like this cause memory leaks:
+ if (self->template_output) + A_WRITE_STRING(&self->dest_buf->super, + c_format("<%i>%S\n", + msg->pri, expand_macros(self->cfg, self->template_output, self->template_escape, msg)));
c_format() has an option to free an ol_string by specifying 'f' like this:
c_format("%fS", expand_macros()) ...
Otherwise your patch looks ok to me. If you want to have it integrated prior to 1.6.0 is being released, please send a modified diff.
In the attachment you find a revised version of the patch. The functions "expand_macros()" & friend are now declared in "macros.h" and coded in "macros.c". The memory leaks are fixed ... Achim
participants (1)
-
Achim Gsell