From: Timo Sirainen Date: Thu, 5 Sep 2019 08:51:44 +0000 (+0300) Subject: lib: Move event_send_callbacks() and event_send_free() earlier in the file X-Git-Tag: 2.3.9~177 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e45e0ac61aa34442e7feae16f22380339bd449a;p=thirdparty%2Fdovecot%2Fcore.git lib: Move event_send_callbacks() and event_send_free() earlier in the file --- diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index b5aca13abc..f7aaceefc2 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -54,6 +54,39 @@ 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); +static bool +event_send_callbacks(struct event *event, enum event_callback_type type, + struct failure_context *ctx, const char *fmt, va_list args) +{ + event_callback_t *const *callbackp; + + array_foreach(&event_handlers, callbackp) { + bool ret; + + T_BEGIN { + ret = (*callbackp)(event, type, ctx, fmt, args); + } T_END; + if (!ret) { + /* event sending was stopped */ + return FALSE; + } + } + return TRUE; +} + +static void event_send_free(struct event *event, ...) +{ + va_list args; + + /* the args are empty and not used for anything, but there doesn't seem + to be any nice and standard way of passing an initialized va_list + as a parameter without va_start(). */ + va_start(args, event); + (void)event_send_callbacks(event, EVENT_CALLBACK_TYPE_FREE, + NULL, NULL, args); + va_end(args); +} + void event_copy_categories(struct event *to, struct event *from) { unsigned int cat_count; @@ -327,26 +360,6 @@ event_create_passthrough(struct event *parent, const char *source_filename, return event_last_passthrough; } -static bool -event_send_callbacks(struct event *event, enum event_callback_type type, - struct failure_context *ctx, const char *fmt, va_list args) -{ - event_callback_t *const *callbackp; - - array_foreach(&event_handlers, callbackp) { - bool ret; - - T_BEGIN { - ret = (*callbackp)(event, type, ctx, fmt, args); - } T_END; - if (!ret) { - /* event sending was stopped */ - return FALSE; - } - } - return TRUE; -} - struct event *event_ref(struct event *event) { i_assert(event->refcount > 0); @@ -355,19 +368,6 @@ struct event *event_ref(struct event *event) return event; } -static void event_send_free(struct event *event, ...) -{ - va_list args; - - /* the args are empty and not used for anything, but there doesn't seem - to be any nice and standard way of passing an initialized va_list - as a parameter without va_start(). */ - va_start(args, event); - (void)event_send_callbacks(event, EVENT_CALLBACK_TYPE_FREE, - NULL, NULL, args); - va_end(args); -} - void event_unref(struct event **_event) { struct event *event = *_event;