Re: [PATCH] commit-slab: clarify slabname##_peek()'s return value
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 10, 2020, 18:19 UTC
- Message-ID
- <xmqqftegjcne.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200310175446.GB549010@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> But that would get a bit awkward, because peek() returns a pointer, not > a value (as it should, because the type we're storing may be a compound > type, which we generally avoid passing or returning by value). So we'd > actually need to return a pointer to a zero-initialized dummy value. Not > impossible, but getting a bit odd.
Do we have a guarantee that callers of the peek only look at, never touch, the location? As long as we make it return a "const *", it might be OK, but a quick look at commit-slab.h tells me that we do not say "const".