summaryrefslogtreecommitdiffstats
path: root/liblog_destroy_context.c
blob: 57192aca4f6fe529f4bceeb6960d18f94790a0d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST

int
liblog_destroy_context(struct liblog_context *ctx)
{
	int ret = 0;

	if (!ctx)
		return 0;

	while (ctx->noutputs)
		ret |= liblog_destroy_output(&ctx->outputs[--ctx->noutputs]);
	free(ctx->outputs);
	ctx->outputs = NULL;

	if (ctx->internal_state) {
		free(ctx->internal_state->msg.prefix);
		free(ctx->internal_state->msg.text);
		free(ctx->internal_state);
		ctx->internal_state = NULL;
	}

	return ret;
}

#else

int main(void) {return 0;} /* TODO test */

#endif