Displaying 6 results from an estimated 6 matches for "safekey".
Did you mean:
sa_key
2020 Aug 26
2
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...25/20 3:32 PM, Eric Blake wrote:
>>> - keys[optind] = strndup (argv[optind], n);
>>> - if (keys[optind] == NULL) {
>>> - perror ("strndup");
>>> + CLEANUP_FREE char *key = strndup (argv[optind], n);
>>> + const char *safekey = nbdkit_string_intern (key);
>>> + if (safekey == NULL)
>>> exit (EXIT_FAILURE);
>>
>> It seems it might also be nice to have a "strndup" version of the
>> intern function.
>
> Or even a memdup. Yeah, those are possibilities as w...
2020 Aug 25
3
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...But I see from the implementation later on
that this isn't the case.
> - keys[optind] = strndup (argv[optind], n);
> - if (keys[optind] == NULL) {
> - perror ("strndup");
> + CLEANUP_FREE char *key = strndup (argv[optind], n);
> + const char *safekey = nbdkit_string_intern (key);
> + if (safekey == NULL)
> exit (EXIT_FAILURE);
It seems it might also be nice to have a "strndup" version of the
intern function.
I'm not completely sure which of these behaviours is better. Ideally
back when I started writing nbdk...
2020 Aug 26
0
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...wrote:
>
> >>>- keys[optind] = strndup (argv[optind], n);
> >>>- if (keys[optind] == NULL) {
> >>>- perror ("strndup");
> >>>+ CLEANUP_FREE char *key = strndup (argv[optind], n);
> >>>+ const char *safekey = nbdkit_string_intern (key);
> >>>+ if (safekey == NULL)
> >>> exit (EXIT_FAILURE);
> >>
> >>It seems it might also be nice to have a "strndup" version of the
> >>intern function.
> >
> >Or even a memdup. Yeah,...
2020 Aug 25
0
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...med to outweigh the need for more
complexity.
>
>> - keys[optind] = strndup (argv[optind], n);
>> - if (keys[optind] == NULL) {
>> - perror ("strndup");
>> + CLEANUP_FREE char *key = strndup (argv[optind], n);
>> + const char *safekey = nbdkit_string_intern (key);
>> + if (safekey == NULL)
>> exit (EXIT_FAILURE);
>
> It seems it might also be nice to have a "strndup" version of the
> intern function.
Or even a memdup. Yeah, those are possibilities as well. Doing all
three (strdu...
2020 Aug 25
0
[nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...p - argv[optind];
if (p && is_config_key (argv[optind], n)) { /* Is it key=value? */
- keys[optind] = strndup (argv[optind], n);
- if (keys[optind] == NULL) {
- perror ("strndup");
+ CLEANUP_FREE char *key = strndup (argv[optind], n);
+ const char *safekey = nbdkit_string_intern (key);
+ if (safekey == NULL)
exit (EXIT_FAILURE);
- }
- top->config (top, keys[optind], p+1);
+ top->config (top, safekey, p+1);
}
else if (magic_config_key == NULL) {
if (i == 0) /* magic script parameter */...
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);