WStream: Refactor: Use reference count for memory management

Now `wstream_write` receives pointers for WBuffer objects(created with
wstream_new_buffer), which stores a reference count to determine when it's safe
the free the buffer. This was done to enable writing of the same buffer to
multiple WStream instances
Add kvec.h macro library
API: Bugfix: Remove possible double-free in buffer_get_line
API: Events: Add support for broadcasting events

The channel_send_event will now broadcast events to all subscribed channels if
the 'id' parameter is 0.
API: Events: Automatically pass channel ids to API functions

The dispatch function generator was customized to allow for API functions to
declare a 'channel_id' as first argument.
API: Events: Add functions for {un}subscribing to broadcasted events
Build: Fix autocmd removal from cleanup function
Channel: Refactor: Extract serialize_event function
Channel: Refactor: Extract register_channel function