From bab2924e89d98b15ee0a344ed04fe226a667612e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 9 May 2005 14:26:10 +0000 Subject: Return -1 to indicate buffer overflow. Allow buffer fill level to be read easily from struct buffer. --- src/include/buffer.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/include') diff --git a/src/include/buffer.h b/src/include/buffer.h index 7ed57fa2b..b0de39df3 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -3,6 +3,18 @@ #include "stdint.h" +/* + * "start" and "end" denote the real boundaries of the buffer. "fill" + * denotes the offset to the first free block in the buffer. (If the + * buffer is full, "fill" will equal ( end - start ) ). + * + */ +struct buffer { + physaddr_t start; + physaddr_t end; + off_t fill; +}; + /* * Free blocks in the buffer start with a "tail byte". If non-zero, * this byte indicates that the free block is the tail of the buffer, @@ -15,24 +27,17 @@ * smaller than a struct buffer_free_block. * */ - struct buffer_free_block { char tail; physaddr_t next_free; physaddr_t end; } __attribute__ (( packed )); -struct buffer { - physaddr_t start; - physaddr_t end; - physaddr_t first_free; -}; - /* Functions in buffer.c */ extern void init_buffer ( struct buffer *buffer, physaddr_t start, size_t len ); -extern off_t fill_buffer ( struct buffer *buffer, void *data, - off_t offset, size_t len ); +extern int fill_buffer ( struct buffer *buffer, void *data, + off_t offset, size_t len ); #endif /* BUFFER_H */ -- cgit v1.2.3-55-g7522