Log subscriber API is not type-safe
We have weston_log_subscriber_create_log()
and weston_log_subscriber_create_flight_rec()
which both return the same type struct weston_log_subscriber *
. However, the API requires that each is destroyed with the right function weston_log_subscriber_destroy_log()
or weston_log_subscriber_destroy_flight_rec()
. There is no type safety that would guarantee that someone calling the wrong destroy function would get a compiler warning.
Either the two create functions need to return distinct types and the two destroy functions need to take the same distinct types, or the create functions stay as is and the destroy functions are both folded into a single weston_log_subscriber_destroy(struct weston_log_subscriber *)
function where it internally then diverges into the specialized cases.
Which way to go? If there is any public API that would apply only to one kind of subscriber, then we must choose distinct types. Otherwise, either solution will do with perhaps a slight preference towards a common destroy function to reduce API surface.