diff options
author | Michael Brown | 2007-07-24 18:11:31 +0200 |
---|---|---|
committer | Michael Brown | 2007-07-24 18:11:31 +0200 |
commit | 9aa61ad5a26e04493a38bf4f9b6bd1228fef7a79 (patch) | |
tree | 3b86aec2b1cc194dca76178c0415c131e8a92b1b /src/core/iobuf.c | |
parent | Define -DOBJECT when generating Makefile rules, for consistency. (diff) | |
download | ipxe-9aa61ad5a26e04493a38bf4f9b6bd1228fef7a79.tar.gz ipxe-9aa61ad5a26e04493a38bf4f9b6bd1228fef7a79.tar.xz ipxe-9aa61ad5a26e04493a38bf4f9b6bd1228fef7a79.zip |
Add per-file error identifiers
Diffstat (limited to 'src/core/iobuf.c')
-rw-r--r-- | src/core/iobuf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/iobuf.c b/src/core/iobuf.c index d04ede51..cc4aedea 100644 --- a/src/core/iobuf.c +++ b/src/core/iobuf.c @@ -17,6 +17,7 @@ */ #include <stdint.h> +#include <errno.h> #include <gpxe/malloc.h> #include <gpxe/iobuf.h> @@ -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; +} + |