diff options
| author | Michael Brown | 2007-01-18 16:13:41 +0100 |
|---|---|---|
| committer | Michael Brown | 2007-01-18 16:13:41 +0100 |
| commit | c8b3e969a0b5da1697efe74d835b53085daabed4 (patch) | |
| tree | 15b5e1c112c0682c8ab7aa00b136b6d388b8d89a /src/include/gpxe | |
| parent | Presize the download buffer when we see the Content-Length header; (diff) | |
| download | ipxe-c8b3e969a0b5da1697efe74d835b53085daabed4.tar.gz ipxe-c8b3e969a0b5da1697efe74d835b53085daabed4.tar.xz ipxe-c8b3e969a0b5da1697efe74d835b53085daabed4.zip | |
Allow buffers to be pre-expanded on demand.
Diffstat (limited to 'src/include/gpxe')
| -rw-r--r-- | src/include/gpxe/buffer.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/gpxe/buffer.h b/src/include/gpxe/buffer.h index b366955c9..72c0846ac 100644 --- a/src/include/gpxe/buffer.h +++ b/src/include/gpxe/buffer.h @@ -2,6 +2,7 @@ #define _GPXE_BUFFER_H #include <stdint.h> +#include <errno.h> #include <gpxe/uaccess.h> /** @file @@ -101,4 +102,24 @@ struct buffer { extern int fill_buffer ( struct buffer *buffer, const void *data, size_t offset, size_t len ); +/** Expand data buffer + * + * @v buffer Data buffer + * @v new_len New length + * @ret rc Return status code + * + * Expand the data buffer to accommodate more data. Some buffers may + * not support being expanded. + */ +static inline int expand_buffer ( struct buffer *buffer, size_t new_len ) { + + if ( new_len <= buffer->len ) + return 0; + + if ( ! buffer->expand ) + return -ENOBUFS; + + return buffer->expand ( buffer, new_len ); +} + #endif /* _GPXE_BUFFER_H */ |
