[PATCH 1/3] cli: add insert --must-index option

David Bremner david at tethera.net
Wed Oct 23 17:05:33 PDT 2013


Austin Clements <amdragon at MIT.EDU> writes:

> And in libnotmuch, we would do something like
>
> notmuch_status_t
> notmuch_database_open (const char *path,
>                        notmuch_database_mode_t mode,
>                        const notmuch_options_t *options,
>                        notmuch_database_t **database)
> {
>     notmuch_option_t real_options = NOTMUCH_OPTIONS_INIT;
>     if (real_options.options_length < options.options_length)
>         return error;
>     memmove(&real_options, options, options.options_length);
>     // ...
> }
>

Does the C standard guarantee that if two structs have the same initial
set of members, that they are aligned in a compatible way? I suppose it
must work, but I'm still curious.

Yet another approach would be to pass in array of descriptors, something
like the command line argument parsing code does now.

libnotmuch_opt_desc_t options[] = {
  { LIBNOTMUCH_OPT_LOGHOOK, loghook },
  { 0, 0} 
}

I guess passing a (void *) as the second element of the pair?

Of course it's a bit more work to unpack this way.


More information about the notmuch mailing list