Re: [PATCH 2/2] use COPY_ARRAY for copying arrays
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Jun 17, 2019, 01:14 UTC
- Message-ID
- <d51041e1-c931-146f-51e7-8a51655dcaa0@gmail.com>
- In-Reply-To
- <e09e49a6-8f6d-1f26-005a-bec5f99414dd@web.de>
On 6/15/2019 2:36 PM, René Scharfe wrote:
> Convert calls of memcpy(3) to use COPY_ARRAY, which shortens and > simplifies the code a bit.
These changes do look simpler. Thanks!
> Patch generated by Coccinelle and contrib/coccinelle/array.cocci.
And this auto-generation is particularly useful!
Show 19 quoted lines
> > Signed-off-by: Rene Scharfe <l.s.r@web.de> > --- > fast-import.c | 2 +- > kwset.c | 2 +- > packfile.c | 6 +++--- > pretty.c | 4 ++-- > 4 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/kwset.c b/kwset.c > index 4fb6455aca..090ffcafa2 100644 > --- a/kwset.c > +++ b/kwset.c > @@ -475,7 +475,7 @@ kwsprep (kwset_t kws) > for (i = 0; i < NCHAR; ++i) > kwset->next[i] = next[U(trans[i])]; > else > - memcpy(kwset->next, next, NCHAR * sizeof(struct trie *)); > + COPY_ARRAY(kwset->next, next, NCHAR);
I was unfamiliar with kwset.c, so I took a look and noticed that it was adapted from GNU grep, so this change takes us even farther from the original source (and closer to Git source conventions).
I think this is the right thing to do, but thought I'd point it out in case anyone thought differently.
Both patches LGTM.
Thanks, -Stolee