Re: [PATCH v2 09/14] config.c: provide kvi with CLI config
- From
Glen Choo <chooglen@google.com>
- Date
- Jun 2, 2023, 17:26 UTC
- Message-ID
- <kl6lmt1hzsfp.fsf@chooglen-macbookpro.roam.corp.google.com>
- In-Reply-To
- <20230601233550.429921-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 7 quoted lines
>> + memcpy(&matched->kvi, kvi, sizeof(struct key_value_info)); > > Can this just be > > matched->kvi = *kvi; > > ?
If I remember correctly (big if), we have to copy the memory because the config machinery allocates kvi on the stack, and the relevant functions have returned by then. Hm, does this suggest that kvi should be const?
> If not, for the sizeof, use *kvi as the argument instead of struct > key_value_info.
Makes sense.