diff options
Diffstat (limited to 'lib/common.h')
-rw-r--r-- | lib/common.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/common.h b/lib/common.h index 36c1a5e..5f07bb7 100644 --- a/lib/common.h +++ b/lib/common.h @@ -39,6 +39,7 @@ #include <limits.h> #include <stdint.h> +#include <sys/uio.h> #define UNUSED __attribute__((unused)) #define EXPORT __attribute__((visibility("default"))) @@ -103,6 +104,16 @@ get_bitmap_size(size_t region_size, size_t pgsize) return ROUND_UP(nr_pages, sizeof(uint64_t) * CHAR_BIT) / CHAR_BIT; } +static inline void +iov_free(struct iovec *iov) +{ + if (iov->iov_base != NULL) { + free(iov->iov_base); + iov->iov_base = NULL; + } + iov->iov_len = 0; +} + #ifdef UNIT_TEST #define MOCK_DEFINE(f) \ |