shl: ring: add shl_ring_flush() helper
This helper flushes all messages from the ring buffer and releases the memory. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
9cc9008866
commit
b626a85206
@ -184,4 +184,19 @@ next:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void shl_ring_flush(struct shl_ring *ring)
|
||||
{
|
||||
struct shl_ring_entry *tmp;
|
||||
|
||||
if (!ring)
|
||||
return;
|
||||
|
||||
while (ring->first) {
|
||||
tmp = ring->first;
|
||||
ring->first = tmp->next;
|
||||
free(tmp);
|
||||
}
|
||||
ring->last = NULL;
|
||||
}
|
||||
|
||||
#endif /* SHL_RING_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user