Index: trunk/src/event.c =================================================================== --- trunk/src/event.c (revision 1241) +++ trunk/src/event.c (revision 1242) @@ -126,3 +126,21 @@ for (e = events[ev]; e != NULL; e = e->next) e->handler(e->user_data, argc, (event_arg_t **) & argv); } + +void events_init(void) +{ + +} + +void events_uninit(void) +{ + int ev; + for(ev = 0; ev < EVENT_last; ev++) { + event_t *e, *next; + for(e = events[ev]; e != NULL; e = next) { + next = e->next; + free(e); + } + } +} + Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 1241) +++ trunk/src/event.h (revision 1242) @@ -26,6 +26,13 @@ } d; } event_arg_t; +/* Initialize the event system */ +void events_init(void); + +/* Uninitialize the event system and remove all events */ +void events_uninit(void); + + /* Event callback prototype; user_data is the same as in event_bind(). argv[0] is always an ARG_INT with the event id that triggered the event. */ typedef void (event_handler_t) (void *user_data, int argc, event_arg_t * argv[]); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 1241) +++ trunk/src/main.c (revision 1242) @@ -60,6 +60,7 @@ #include "paths.h" #include "strflags.h" #include "plugins.h" +#include "event.h" #include "hid/common/actions.h" @@ -1585,6 +1586,7 @@ PCB = NULL; plugins_uninit(); + events_uninit(); for (i = 0; i < MAX_LAYER; i++) free(Settings.DefaultLayerName[i]); @@ -1798,6 +1800,8 @@ */ atexit(EmergencySave); + events_init(); + /* read the library file and display it if it's not empty */ if (!ReadLibraryContents() && Library.MenuN)