From bf32d26490a6fd688194f67856563f0a5a843668 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 17 Jun 2017 18:39:07 +0200 Subject: kern/cbuf: use size_t instead of unsigned long --- kern/cbuf.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'kern/cbuf.h') diff --git a/kern/cbuf.h b/kern/cbuf.h index 3ea3841..b675fd5 100644 --- a/kern/cbuf.h +++ b/kern/cbuf.h @@ -21,6 +21,8 @@ #ifndef _KERN_CBUF_H #define _KERN_CBUF_H +#include + /* * Circular buffer descriptor. * @@ -29,30 +31,30 @@ */ struct cbuf { char *buf; - unsigned long capacity; - unsigned long start; - unsigned long end; + size_t capacity; + size_t start; + size_t end; }; -static inline unsigned long +static inline size_t cbuf_capacity(const struct cbuf *cbuf) { return cbuf->capacity; } -static inline unsigned long +static inline size_t cbuf_start(const struct cbuf *cbuf) { return cbuf->start; } -static inline unsigned long +static inline size_t cbuf_end(const struct cbuf *cbuf) { return cbuf->end; } -static inline unsigned long +static inline size_t cbuf_size(const struct cbuf *cbuf) { return cbuf->end - cbuf->start; @@ -70,7 +72,7 @@ cbuf_clear(struct cbuf *cbuf) * The descriptor is set to use the given buffer for storage. Capacity * must be a power-of-two. */ -void cbuf_init(struct cbuf *cbuf, char *buf, unsigned long capacity); +void cbuf_init(struct cbuf *cbuf, char *buf, size_t capacity); /* * Append a byte to a circular buffer. @@ -96,6 +98,6 @@ int cbuf_pop(struct cbuf *cbuf, char *bytep); * Otherwise the byte is stored at the bytep address and 0 is returned. * The buffer isn't changed by this operation. */ -int cbuf_read(const struct cbuf *cbuf, unsigned long index, char *bytep); +int cbuf_read(const struct cbuf *cbuf, size_t index, char *bytep); #endif /* _KERN_CBUF_H */ -- cgit v1.2.3