On 01/03/2012 10:09 AM, Jim Meyering wrote:
> MALLOC(grps[ngrps].elems, d->nleaves);
> - copy(&grps[j],&grps[ngrps]);
> + memcpy(grps[ngrps].elems, grps[j].elems,
> + grps[j].nelem * sizeof(unsigned int));
> + grps[ngrps].nelem = grps[j].nelem;
While slightly longer, the following is also slightly safer.
If the type of "elems" ever changes, we won't need to realize the
"sizeof(unsigned int)" above must also be changed to match that new type:
memcpy(grps[ngrps].elems, grps[j].elems,
grps[j].nelem * sizeof(*(grps[j].elems)));
Agreed, thanks!
Paolo