aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/degesch.c b/degesch.c
index 6aab330..6fce8c8 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1045,22 +1045,21 @@ struct buffer_line
int flags; ///< Flags
time_t when; ///< Time of the event
- struct formatter *formatter; ///< Line data
+ struct formatter formatter; ///< Line data
};
struct buffer_line *
-buffer_line_new (void)
+buffer_line_new (struct formatter *f)
{
struct buffer_line *self = xcalloc (1, sizeof *self);
+ self->formatter = *f;
return self;
}
static void
buffer_line_destroy (struct buffer_line *self)
{
- if (self->formatter)
- formatter_free (self->formatter);
- free (self->formatter);
+ formatter_free (&self->formatter);
free (self);
}
@@ -3052,7 +3051,7 @@ buffer_line_flush (struct buffer_line *line, struct formatter *f, FILE *output,
if (flags & BUFFER_LINE_STATUS) formatter_add (f, " - ");
if (flags & BUFFER_LINE_ERROR) formatter_add (f, "#a=!=#r ", ATTR_ERROR);
- formatter_add_from (f, line->formatter);
+ formatter_add_from (f, &line->formatter);
formatter_add (f, "\n");
formatter_flush (f, output, raw_attributes);
formatter_free (f);
@@ -3142,14 +3141,11 @@ log_formatter (struct app_context *ctx,
if (!buffer)
buffer = ctx->global_buffer;
- struct buffer_line *line = buffer_line_new ();
+ // Move the formatter inside
+ struct buffer_line *line = buffer_line_new (f);
line->flags = flags;
line->when = time (NULL);
- // Move the formatter inside
- line->formatter = xmalloc (sizeof *line->formatter);
- *line->formatter = *f;
-
buffer_pop_excess_lines (ctx, buffer);
LIST_APPEND_WITH_TAIL (buffer->lines, buffer->lines_tail, line);
buffer->lines_count++;