out_counter: use new flb_mp_count() prototype
struct flb_counter_ctx {
uint64_t total;
- msgpack_zone *zone;
};
-int cb_counter_init(struct flb_output_instance *ins,
+static int cb_counter_init(struct flb_output_instance *ins,
struct flb_config *config,
void *data)
{
@@ -46,17 +45,12 @@ int cb_counter_init(struct flb_output_instance *ins,
return -1;
}
ctx->total = 0;
- ctx->zone = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
- if (!ctx->zone) {
- flb_free(ctx);
- return -1;
- }
-
flb_output_set_context(ins, ctx);
+
return 0;
}
-void cb_counter_flush(const void *data, size_t bytes,
+static void cb_counter_flush(const void *data, size_t bytes,
const char *tag, int tag_len,
struct flb_input_instance *i_ins,
void *out_context,
@@ -74,7 +68,7 @@ void cb_counter_flush(const void *data, size_t bytes,
struct flb_time tm;
/* Count number of parent items */
- cnt = flb_mp_count_zone(data, bytes, ctx->zone);
+ cnt = flb_mp_count(data, bytes);
ctx->total += cnt;
flb_time_get(&tm);
@@ -84,11 +78,14 @@ void cb_counter_flush(const void *data, size_t bytes,
FLB_OUTPUT_RETURN(FLB_OK);
}
-int cb_counter_exit(void *data, struct flb_config *config)
+static int cb_counter_exit(void *data, struct flb_config *config)
{
struct flb_counter_ctx *ctx = data;
- msgpack_zone_free(ctx->zone);
+ if (!ctx) {
+ return 0;
+ }
+
flb_free(ctx);
return 0;
}
