summaryrefslogtreecommitdiff
path: root/kern/cbuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'kern/cbuf.h')
-rw-r--r--kern/cbuf.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/kern/cbuf.h b/kern/cbuf.h
index 0558cc09..a30e5f28 100644
--- a/kern/cbuf.h
+++ b/kern/cbuf.h
@@ -21,6 +21,7 @@
#ifndef _KERN_CBUF_H
#define _KERN_CBUF_H
+#include <stdbool.h>
#include <stddef.h>
/*
@@ -66,6 +67,12 @@ cbuf_clear(struct cbuf *cbuf)
cbuf->start = cbuf->end;
}
+static inline bool
+cbuf_range_valid(const struct cbuf *cbuf, size_t start, size_t end)
+{
+ return ((end - start) <= cbuf_size(cbuf));
+}
+
/*
* Initialize a circular buffer.
*