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;
|
||||
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);
|
||||
EventNode * event_create(const EventData * content);
|
||||
void event_destroy(EventNode * self);
|
||||
void event_destroy_all();
|
||||
|
||||
#endif /* end of include guard: EVENTS_H_ */
|
||||
|
|
Loading…
Reference in New Issue