From: Josef 'Jeff' Sipek Date: Fri, 15 Mar 2019 00:21:15 +0000 (-0400) Subject: lib: replace event_copy_categories_fields() into two X-Git-Tag: 2.3.9~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da5ba8b44203d9bc3de4bbf3a70239a39c7a8e49;p=thirdparty%2Fdovecot%2Fcore.git lib: replace event_copy_categories_fields() into two It is more flexible to allow to copy only categories or only fields. --- diff --git a/src/lib-master/stats-client.c b/src/lib-master/stats-client.c index 6cea2313c2..5acf197f6b 100644 --- a/src/lib-master/stats-client.c +++ b/src/lib-master/stats-client.c @@ -176,7 +176,8 @@ static struct event *stats_event_get_merged(struct event *event) res = event_dup(event); use_original = FALSE; } - event_copy_categories_fields(res, p); + event_copy_categories(res, p); + event_copy_fields(res, p); } } diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index ffa4a85760..20b985db38 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -54,12 +54,16 @@ event_find_category(struct event *event, const struct event_category *category); static struct event_field * event_find_field_int(struct event *event, const char *key); -void event_copy_categories_fields(struct event *to, struct event *from) +void event_copy_categories(struct event *to, struct event *from) { unsigned int cat_count; struct event_category *const *categories = event_get_categories(from, &cat_count); while (cat_count-- > 0) event_add_category(to, categories[cat_count]); +} + +void event_copy_fields(struct event *to, struct event *from) +{ const struct event_field *fld; if (!array_is_created(&from->fields)) return; diff --git a/src/lib/lib-event.h b/src/lib/lib-event.h index 5efe4bc13f..e598044572 100644 --- a/src/lib/lib-event.h +++ b/src/lib/lib-event.h @@ -87,10 +87,14 @@ bool event_has_all_fields(struct event *event, const struct event *other); /* Returns the source event duplicated into a new event. */ struct event *event_dup(const struct event *source); -/* Copy all categories and fields from source to dest. - Only the fields and categories in source event itself are copied. - Parent events' fields and categories aren't copied. */ -void event_copy_categories_fields(struct event *dest, struct event *source); +/* Copy all categories from source to dest. + Only the categories in source event itself are copied. + Parent events' categories aren't copied. */ +void event_copy_categories(struct event *to, struct event *from); +/* Copy all fields from source to dest. + Only the fields in source event itself are copied. + Parent events' fields aren't copied. */ +void event_copy_fields(struct event *to, struct event *from); /* Create a new empty event under the parent event, or NULL for root event. */ struct event *event_create(struct event *parent, const char *source_filename,