git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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".

Previous: Jeff KingNext: Junio C Hamano
Message 5 of 6 in “commit-slab: clarify slabname##_peek()'s return value”
  1. commit-slab: clarify slabname##_peek()'s return valueSZEDER Gábor, Mar 10, 2020
  2. Jeff KingMar 10, 2020
  3. Jeff KingMar 10, 2020
  4. Jeff KingMar 11, 2020
  5. Junio C HamanoMar 10, 2020
  6. Junio C HamanoMar 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.