Skip to content

Commit 209e8a5

Browse files
committed
out_counter: use new flb_mp_count() prototype
Signed-off-by: Eduardo Silva <[email protected]>
1 parent ff9e156 commit 209e8a5

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

plugins/out_counter/counter.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@
2828

2929
struct flb_counter_ctx {
3030
uint64_t total;
31-
msgpack_zone *zone;
3231
};
3332

34-
int cb_counter_init(struct flb_output_instance *ins,
35-
struct flb_config *config,
36-
void *data)
33+
static int cb_counter_init(struct flb_output_instance *ins,
34+
struct flb_config *config,
35+
void *data)
3736
{
3837
(void) ins;
3938
(void) config;
@@ -46,21 +45,16 @@ int cb_counter_init(struct flb_output_instance *ins,
4645
return -1;
4746
}
4847
ctx->total = 0;
49-
ctx->zone = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
50-
if (!ctx->zone) {
51-
flb_free(ctx);
52-
return -1;
53-
}
54-
5548
flb_output_set_context(ins, ctx);
49+
5650
return 0;
5751
}
5852

59-
void cb_counter_flush(const void *data, size_t bytes,
60-
const char *tag, int tag_len,
61-
struct flb_input_instance *i_ins,
62-
void *out_context,
63-
struct flb_config *config)
53+
static void cb_counter_flush(const void *data, size_t bytes,
54+
const char *tag, int tag_len,
55+
struct flb_input_instance *i_ins,
56+
void *out_context,
57+
struct flb_config *config)
6458
{
6559
(void) data;
6660
(void) bytes;
@@ -74,7 +68,7 @@ void cb_counter_flush(const void *data, size_t bytes,
7468
struct flb_time tm;
7569

7670
/* Count number of parent items */
77-
cnt = flb_mp_count_zone(data, bytes, ctx->zone);
71+
cnt = flb_mp_count(data, bytes);
7872
ctx->total += cnt;
7973

8074
flb_time_get(&tm);
@@ -84,11 +78,14 @@ void cb_counter_flush(const void *data, size_t bytes,
8478
FLB_OUTPUT_RETURN(FLB_OK);
8579
}
8680

87-
int cb_counter_exit(void *data, struct flb_config *config)
81+
static int cb_counter_exit(void *data, struct flb_config *config)
8882
{
8983
struct flb_counter_ctx *ctx = data;
9084

91-
msgpack_zone_free(ctx->zone);
85+
if (!ctx) {
86+
return 0;
87+
}
88+
9289
flb_free(ctx);
9390
return 0;
9491
}

0 commit comments

Comments
 (0)