Add global event list destructor
This commit is contained in:
parent
5875575d0b
commit
c2a723098f
12
events.c
12
events.c
|
@ -72,3 +72,15 @@ event_destroy(EventNode * self)
|
||||||
self->next = NULL;
|
self->next = NULL;
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void event_destroy_all()
|
||||||
|
{
|
||||||
|
EventNode *ev;
|
||||||
|
while ((ev = FIRST_EVENT) != &END_EVENTS) {
|
||||||
|
event_destroy(ev);
|
||||||
|
if (ev == FIRST_EVENT) {
|
||||||
|
fprintf(stderr, "Broken doubly linked event list invariant\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
events.h
1
events.h
|
@ -47,5 +47,6 @@ extern EventNode END_EVENTS;
|
||||||
size_t event_replicate(EventNode * source, size_t count);
|
size_t event_replicate(EventNode * source, size_t count);
|
||||||
EventNode * event_create(const EventData * content);
|
EventNode * event_create(const EventData * content);
|
||||||
void event_destroy(EventNode * self);
|
void event_destroy(EventNode * self);
|
||||||
|
void event_destroy_all();
|
||||||
|
|
||||||
#endif /* end of include guard: EVENTS_H_ */
|
#endif /* end of include guard: EVENTS_H_ */
|
||||||
|
|
1
main.c
1
main.c
|
@ -82,6 +82,7 @@ main(int argc, char ** argv)
|
||||||
for (ssize_t i = loaded_config.nodes.length - 1; i >= 0; --i) {
|
for (ssize_t i = loaded_config.nodes.length - 1; i >= 0; --i) {
|
||||||
graph_node_delete(nodes[i]);
|
graph_node_delete(nodes[i]);
|
||||||
}
|
}
|
||||||
|
event_destroy_all();
|
||||||
free(channels);
|
free(channels);
|
||||||
free(nodes);
|
free(nodes);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue