From: Junio C Hamano Date: Thu, 09 Jan 2025 18:05:41 GMT Subject: Re: [PATCH 02/14] combine-diff: add combine_diff_path_new() Message-ID: In-Reply-To: <20250109083236.GB2748836@coredump.intra.peff.net> Jeff King writes: > +struct combine_diff_path *combine_diff_path_new(const char *path, > + size_t path_len, > + unsigned int mode, > + const struct object_id *oid, > + size_t num_parents) > +{ > + struct combine_diff_path *p; > + > + p = xmalloc(combine_diff_path_size(num_parents, path_len)); > + p->path = (char *)&(p->parent[num_parents]); > + memcpy(p->path, path, path_len); > + p->path[path_len] = 0; > + p->next = NULL; > + p->mode = mode; > + oidcpy(&p->oid, oid); > + > + memset(p->parent, 0, sizeof(p->parent[0]) * num_parents); > + > + return p; > +} OK, I can see how the structure is laid out clearly in this code, but I have to say it is one ugly hack X-<. At least with the refactoring, it becomes much easier to see what the caller is doing.