search for: int64_vector_append

Displaying 4 results from an estimated 4 matches for "int64_vector_append".

2020 Jul 07
0
[nbdkit PATCH 1/3] vector: Add VECT_remove
...OR_TYPE(string_vector, char *); +static int +compare (const int64_t *a, const int64_t *b) +{ + return (*a > *b) - (*a < *b); +} + static void test_int64_vector (void) { int64_vector v = empty_vector; size_t i; int r; + int64_t tmp, *p; for (i = 0; i < 10; ++i) { - r = int64_vector_append (&v, i); + r = int64_vector_insert (&v, i, 0); assert (r == 0); } + + for (i = 0; i < 10; ++i) + assert (v.ptr[i] == 9 - i); + int64_vector_sort (&v, compare); for (i = 0; i < 10; ++i) assert (v.ptr[i] == i); + + r = int64_vector_remove (&v, 1); + ass...
2020 Apr 15
0
[PATCH nbdkit 1/9] common: Add a generic implementation of vectors.
...stdint.h> +#include <assert.h> + +#include "vector.h" + +DEFINE_VECTOR_TYPE(int64_vector, int64_t); +DEFINE_VECTOR_TYPE(string_vector, char *); + +static void +test_int64_vector (void) +{ + int64_vector v = empty_vector; + size_t i; + + for (i = 0; i < 10; ++i) + assert (int64_vector_append (&v, i) == 0); + for (i = 0; i < 10; ++i) + assert (v.ptr[i] == i); + free (v.ptr); +} + +static void +test_string_vector (void) +{ + string_vector v = empty_vector; + size_t i; + + for (i = 0; i < 10; ++i) { + char *s; + + assert (asprintf (&s, "number %zu", i...
2020 Jul 07
6
[RFC nbdkit PATCH 0/3] aligned .extents
Ultimately, both the blocksize and swab filters want to return aligned extents to the client. I'm posting this as a snapshot of my work in progress on how I plan to get there (it's not quite working yet, but I'm done for today and wanted to at least document my ideas). I might also add a convenience function for nbdkit_extents_offset, since we have a number of filters that repeat the
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.