From 42bcaf301e9e06836e0a504b211b7fa95260493f Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 10 Nov 2010 11:41:21 +0100 Subject: store fuse_buf inside fuse_bufvec Store the first fuse_buf inside fuse_bufvec. This makes initialization of fuse_bufvec simpler for the common case of a single fuse_buf. If multiple fuse_buf's are needed then fuse_bufvec needs to be dynamically allocated. --- include/fuse_common.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'include/fuse_common.h') diff --git a/include/fuse_common.h b/include/fuse_common.h index ea8974d..233a0b4 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -368,13 +368,10 @@ struct fuse_buf { * * An array of data buffers, each containing a memory pointer or a * file descriptor. + * + * Allocate dynamically to add more than one buffer. */ struct fuse_bufvec { - /** - * Array of buffers - */ - const struct fuse_buf *buf; - /** * Number of buffers in the array */ @@ -389,8 +386,28 @@ struct fuse_bufvec { * Current offset within the current buffer */ size_t off; + + /** + * Array of buffers + */ + struct fuse_buf buf[1]; }; +/* Initialize bufvec with a single buffer of given size */ +#define FUSE_BUFVEC_INIT(size__) \ + ((struct fuse_bufvec) { \ + /* .count= */ 1, \ + /* .idx = */ 0, \ + /* .off = */ 0, \ + /* .buf = */ { /* [0] = */ { \ + /* .size = */ (size__), \ + /* .flags = */ (enum fuse_buf_flags) 0, \ + /* .mem = */ NULL, \ + /* .fd = */ -1, \ + /* .pos = */ 0, \ + } } \ + } ) + /** * Get total size of data in a fuse buffer vector * -- cgit v1.2.3