From: "Todd C. Miller" Subject: Re: reuse tree entries array while parsing trees To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Tue, 18 Oct 2022 14:42:09 -0600 On Tue, 18 Oct 2022 22:15:57 +0200, Stefan Sperling wrote: > This patch avoids a per-tree malloc/free dance in got-read-tree > and got-read-pack while parsing trees. > > Instead of throwing the parsed-tree-entries array away after > parsing a tree, we can leave its memory allocation in place, > and keep extending it as needed with recallocarray(). Previously the newly-allocated memory was always zeroed out. Now that you are re-using the old allocation do you also need to zero it before re-use? I can't tell whether the callers really expect zeroed memory or if this was just to be on the safe side. - todd