1 /* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
2 
3 #include "lib.h"
4 #include "stats-event-category.h"
5 
6 static pool_t categories_pool;
7 
stats_event_category_register(const char * name,struct event_category * parent)8 void stats_event_category_register(const char *name,
9 				   struct event_category *parent)
10 {
11 	struct event_category *category =
12 		p_new(categories_pool, struct event_category, 1);
13 	category->parent = parent;
14 	category->name = p_strdup(categories_pool, name);
15 
16 	/* Create a temporary event to register the category. A bit slower
17 	   than necessary, but this code won't be called often. */
18 	struct event *event = event_create(NULL);
19 	struct event_category *categories[] = { category, NULL };
20 	event_add_categories(event, categories);
21 	event_unref(&event);
22 }
23 
stats_event_categories_init(void)24 void stats_event_categories_init(void)
25 {
26 	categories_pool = pool_alloconly_create("categories", 1024);
27 }
28 
stats_event_categories_deinit(void)29 void stats_event_categories_deinit(void)
30 {
31 	pool_unref(&categories_pool);
32 }
33