search for: generic_vector

Displaying 7 results from an estimated 7 matches for "generic_vector".

2020 Apr 15
1
Re: [PATCH nbdkit 1/9] common: Add a generic implementation of vectors.
...\ > + static inline int \ > + name##_extend (name *v, size_t n) \ > + { \ > + return generic_vector_extend ((struct generic_vector *)v, n, \ > + sizeof (type)); \ > + } \ > + static inline int \ > + nam...
2020 Oct 27
0
[PATCH libnbd 1/5] common/utils: Copy simple vector library from nbdkit.
...LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "vector.h" + +int +generic_vector_reserve (struct generic_vector *v, size_t n, size_t itemsize) +{ + void *newptr; + + newptr = realloc (v->ptr, (n + v->alloc) * itemsize); + if (newptr == NULL) + return -1; + v->ptr = newptr; + v->alloc += n; + return 0; +} diff --git a/common/utils/vector.h b/common/utils/vec...
2020 Apr 15
0
[PATCH nbdkit 1/9] common: Add a generic implementation of vectors.
...truct name name; \ + static inline int \ + name##_extend (name *v, size_t n) \ + { \ + return generic_vector_extend ((struct generic_vector *)v, n, \ + sizeof (type)); \ + } \ + static inline int \ + name##_append (name *v,...
2020 Apr 15
18
[PATCH nbdkit 0/9] Generic vector, and pass $nbdkit_stdio_safe to shell scripts.
This was a rather longer trip around the houses than I anticipated! The basic purpose of the patch series is to set $nbdkit_stdio_safe to "0" or "1" in sh and eval plugin scripts. To do that, I ended up adding a nicer way to manipulate environ lists, and to do that, I ended up adding a whole generic vector implementation which is applicable in a lot of different places.
2020 Oct 27
6
[PATCH libnbd 0/5] info: --map: Coalesce adjacent extents of the same type.
This adds coalescing of adjacent extents of the same type, as mentioned by Eric Blake in the commit message here: https://github.com/libguestfs/libnbd/commit/46072f6611f80245846a445766da071e457b00cd The patch series is rather long because it detours through adding the <vector.h> library from nbdkit into libnbd and replacing ad hoc uses of realloc, char ** etc in various places. Rich.
2020 Apr 19
0
[PATCH nbdkit 2/2] Add insert function and use the new vector library in several places.
...t. */ #ifndef NBDKIT_VECTOR_H #define NBDKIT_VECTOR_H #include <assert.h> +#include <string.h> #define DEFINE_VECTOR_TYPE(name, type) \ struct name { \ @@ -55,15 +57,23 @@ return generic_vector_extend ((struct generic_vector *)v, n, \ sizeof (type)); \ } \ + /* Insert at i'th element. i=0 => beginning i=size => append */ \ static inline...
2020 Apr 19
2
[PATCH nbdkit 1/2] vddk: Use new vector library to allocate the argv list.
--- plugins/vddk/vddk.c | 41 +++++++++++++++++++++++++---------------- TODO | 1 - 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c index 87c0d146..d1a3015f 100644 --- a/plugins/vddk/vddk.c +++ b/plugins/vddk/vddk.c @@ -51,6 +51,7 @@ #include "isaligned.h" #include "minmax.h" #include