search for: string_vector_it

Displaying 18 results from an estimated 18 matches for "string_vector_it".

Did you mean: string_vector_iter
2023 Jan 31
1
[PATCH libnbd] generator: Pass LISTEN_FDNAMES=nbd with systemd socket activation
...he prefix length Sure, go for it please. > (2) Pre-patch, at commit 5a02c7d2cc6a, the error handling tail of > prepare_socket_activation_environment() is less than ideal, IMO. Namely, > we have (excerpt) > > > err: > > set_error (errno, "malloc"); > > string_vector_iter (env, (void *) free); > > free (env->ptr); > > return -1; > > (2a) we free the vector's pointer field, but don't NULL it, nor do we > zero the len or cap fields. > > We should call string_vector_reset() instead. Yup. > (2b) Casting the address of t...
2023 Jan 31
1
[PATCH libnbd] generator: Pass LISTEN_FDNAMES=nbd with systemd socket activation
...ent of the array -- use "sizeof" for grabbing the prefix length (2) Pre-patch, at commit 5a02c7d2cc6a, the error handling tail of prepare_socket_activation_environment() is less than ideal, IMO. Namely, we have (excerpt) > err: > set_error (errno, "malloc"); > string_vector_iter (env, (void *) free); > free (env->ptr); > return -1; (2a) we free the vector's pointer field, but don't NULL it, nor do we zero the len or cap fields. We should call string_vector_reset() instead. (2b) Casting the address of the free() function to (void*) makes me uncomfo...
2023 Feb 15
1
[libnbd PATCH v3 05/29] vector: (mostly) factor out DEFINE_VECTOR_EMPTY
On Wed, Feb 15, 2023 at 03:11:34PM +0100, Laszlo Ersek wrote: > The "name##_iter" function is used 11 times in libnbd; in all those cases, > "name" is "string_vector", and the "f" callback is "free": > > string_vector_iter (..., (void *) free); > > Casting "free" to (void*) is ugly. (Well-defined by POSIX, but still.) Tangentially related: casting function pointers in general may get harder as more compilers move towards C23 and its newer rules (see for example https://lists.gnu.org/archive/html/b...
2020 Jul 14
3
[PATCH nbdkit RFC 0/2] curl: Implement authorization scripts.
This is an RFC only, at the very least it lacks tests. This implements a rather complex new feature in nbdkit-curl-plugin allowing you to specify an external shell script that can be used to fetch an authorization token for services which requires a token or cookie for access, especially if that token must be renewed periodically. The motivation can be seen in the changes to the docs in patch 2.
2023 Jan 28
1
[PATCH libnbd] generator: Pass LISTEN_FDNAMES=nbd with systemd socket activation
systemd allows sockets passed through socket activation to be named with the protocol they require. We only ever pass one socket, name it. This environment variable is currently ignored by qemu-nbd and nbdkit, but might be used by qemu-storage-daemon: https://lists.nongnu.org/archive/html/qemu-devel/2023-01/msg06114.html --- generator/states-connect-socket-activation.c | 41
2020 Jul 14
0
[PATCH nbdkit RFC 2/2] curl: Implement authorization scripts.
...ist of extra headers and cookies from the output of auth-script. */ +DEFINE_VECTOR_TYPE(string_vector, char *); +static string_vector script_headers = empty_vector; +static string_vector script_cookies = empty_vector; + +/* Called from plugin curl_unload(). */ +void +auth_script_unload (void) +{ + string_vector_iter (&script_headers, (void *) free); + string_vector_iter (&script_cookies, (void *) free); + free (script_headers.ptr); + free (script_cookies.ptr); +} + +static int run_auth_script (struct curl_handle *); +static int set_headers (struct curl_handle *); +static int set_cookies (struct cu...
2020 Jun 02
0
[PATCH nbdkit 2/5] vddk: Move reexec code to a new file.
...uot;vddk.h" + +char *reexeced; /* orig LD_LIBRARY_PATH on reexec */ + +DEFINE_VECTOR_TYPE(string_vector, char *); + +#define CLEANUP_FREE_STRING_VECTOR \ + __attribute__((cleanup (cleanup_free_string_vector))) + +static void +cleanup_free_string_vector (string_vector *v) +{ + string_vector_iter (v, (void *) free); + free (v->ptr); +} + +/* Perform a re-exec that temporarily modifies LD_LIBRARY_PATH. Does + * not return on success; on failure, problems have been logged, but + * the caller prefers to proceed as if this had not been attempted. + * Thus, no return value is needed. + */...
2020 Apr 15
0
[PATCH nbdkit 2/9] floppy, iso, split, ssh: Use new vector type to store lists of strings.
...+ shell_quote (dirs.ptr[i], fp); } /* Redirect output to the temporary file. */ fprintf (fp, " >&%d", fd); @@ -122,11 +123,8 @@ make_iso (void) static void iso_unload (void) { - size_t i; - - for (i = 0; i < nr_dirs; ++i) - free (dirs[i]); - free (dirs); + string_vector_iter (&dirs, (void *) free); + free (dirs.ptr); if (fd >= 0) close (fd); @@ -135,7 +133,6 @@ iso_unload (void) static int iso_config (const char *key, const char *value) { - char **new_dirs; char *dir; if (strcmp (key, "dir") == 0) { @@ -143,15 +140,11 @@ iso_co...
2020 Apr 15
0
[PATCH nbdkit 1/9] common: Add a generic implementation of vectors.
...ector_append (&v, NULL) == 0); + + /* Now print them. */ + for (i = 0; v.ptr[i] != NULL; ++i) + printf ("%s\n", v.ptr[i]); + assert (i == 10); + + /* And free them. We can use the generated iter function here + * even though it calls free on the final NULL pointer. + */ + string_vector_iter (&v, (void*)free); + free (v.ptr); +} + +int +main (int argc, char *argv[]) +{ + test_int64_vector (); + test_string_vector (); +} diff --git a/common/include/vector.h b/common/include/vector.h new file mode 100644 index 00000000..69a350be --- /dev/null +++ b/common/include/vector.h @@ -0,...
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.
2023 Feb 22
2
[libnbd PATCH v3 05/29] vector: (mostly) factor out DEFINE_VECTOR_EMPTY
...0100, Laszlo Ersek wrote: > >>>> The "name##_iter" function is used 11 times in libnbd; in all those cases, > >>>> "name" is "string_vector", and the "f" callback is "free": > >>>> > >>>> string_vector_iter (..., (void *) free); > >>>> > >>>> Casting "free" to (void*) is ugly. (Well-defined by POSIX, but still.) > >>> > >>> Tangentially related: casting function pointers in general may get > >>> harder as more compilers move...
2020 Aug 25
0
[nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...klen_t *addrlen) return 0; } + +/* Functions for manipulating intern'd strings. */ + +static string_vector global_interns; + +void +free_interns (void) +{ + struct connection *conn = threadlocal_get_conn (); + string_vector *list = conn ? &conn->interns : &global_interns; + + string_vector_iter (list, (void *) free); + string_vector_reset (list); +} + +const char * +nbdkit_string_intern (const char *str) +{ + struct connection *conn = threadlocal_get_conn (); + string_vector *list = conn ? &conn->interns : &global_interns; + char *copy; + + if (str == NULL) { + nbdkit...
2020 Aug 27
0
[nbdkit PATCH v2 4/8] api: Add nbdkit_str[n]dup_intern helper
...klen_t *addrlen) return 0; } + +/* Functions for manipulating intern'd strings. */ + +static string_vector global_interns; + +void +free_interns (void) +{ + struct connection *conn = threadlocal_get_conn (); + string_vector *list = conn ? &conn->interns : &global_interns; + + string_vector_iter (list, (void *) free); + string_vector_reset (list); +} + +const char * +nbdkit_strndup_intern (const char *str, size_t n) +{ + struct connection *conn = threadlocal_get_conn (); + string_vector *list = conn ? &conn->interns : &global_interns; + char *copy; + + if (str == NULL) {...
2020 Jun 02
9
[PATCH nbdkit 0/5] vddk: Fix password parameter.
Probably needs a bit of cleanup, but seems like it is generally the right direction. One thing I've noticed is that the expect test randomly (but rarely) hangs :-( I guess something is racey but I don't know what at the moment. Rich.
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 Apr 19
2
[PATCH nbdkit 1/2] vddk: Use new vector library to allocate the argv list.
...rs to proceed as if this had not been attempted. * Thus, no return value is needed. */ +DEFINE_VECTOR_TYPE(string_vector, char *); + +#define CLEANUP_FREE_STRING_VECTOR \ + __attribute__((cleanup (cleanup_free_string_vector))) + +static void +cleanup_free_string_vector (string_vector *v) +{ + string_vector_iter (v, (void *) free); + free (v->ptr); +} + static void perform_reexec (const char *env, const char *prepend) { CLEANUP_FREE char *library = NULL; - int argc = 0; - CLEANUP_FREE char **argv = NULL; + CLEANUP_FREE_STRING_VECTOR string_vector argv = empty_vector; int fd; size_t len...
2020 Aug 25
9
[nbdkit PATCH 0/5] Implement .default_export, nbdkit_string_intern
More patches on the way for improving .list_exports signature and adding .export_description, but this is the promised code showing why nbdkit_string_intern is useful. Patch 4 is somewhat RFC: we could either add new API to take the boilerplate from: foo_config(const char *key, const char *value) { if (strcmp (key, "file") == 0) { CLEANUP_FREE char *tmp = nbdkit_realpath (value);
2020 Aug 27
10
[nbdkit PATCH v2 0/8] exportname filter
This is a revision of my .default_export work, plus new work on .export_descriptions and a new exportname filter. I think it is now ready to check in. Things I'd still like in 1.22: - the file plugin should implement .list_exports (patch already posted, but it needs rebasing on this series) - the ext2 filter should override .list_exports when in exportname mode - the nbd plugin should be