From 9aa61ad5a26e04493a38bf4f9b6bd1228fef7a79 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 24 Jul 2007 17:11:31 +0100 Subject: Add per-file error identifiers --- src/core/iobuf.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core') diff --git a/src/core/iobuf.c b/src/core/iobuf.c index d04ede514..cc4aedeae 100644 --- a/src/core/iobuf.c +++ b/src/core/iobuf.c @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -72,3 +73,22 @@ void free_iob ( struct io_buffer *iobuf ) { ( iobuf->end - iobuf->head ) + sizeof ( *iobuf ) ); } } + +/** + * Ensure I/O buffer has sufficient headroom + * + * @v iobuf I/O buffer + * @v len Required headroom + * + * This function currently only checks for the required headroom; it + * does not reallocate the I/O buffer if required. If we ever have a + * code path that requires this functionality, it's a fairly trivial + * change to make. + */ +int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len ) { + + if ( iob_headroom ( iobuf ) >= len ) + return 0; + return -ENOBUFS; +} + -- cgit v1.2.3-55-g7522