diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-21 16:31:32 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-21 16:33:38 +0300 |
commit | 34e9716fb28c4128d7cfee24a910a47abeb2aa98 (patch) | |
tree | 3a8d076f329649e09a2c2e52be3893e4ee511696 /events.c | |
parent | d93ee5f7009bbd81631bd7f8493486051a732a23 (diff) |
events: Add a cleanup function
Add events to the watch list allocates memory. Add a cleanup function to
free all memory at cleanup time without having to remove all events
explicitly one by one.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'events.c')
-rw-r--r-- | events.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -181,3 +181,14 @@ void events_init(struct events *events) events->maxfd = 0; list_init(&events->events); } + +void events_cleanup(struct events *events) +{ + while (!list_empty(&events->events)) { + struct event_fd *event; + + event = list_first_entry(&events->events, typeof(*event), list); + list_remove(&event->list); + free(event); + } +} |