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

Re: [PATCH 5/6] test-hashmap: simplify alloc_test_entry

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2018, 19:01 UTC
Message-ID
<xmqq3723o0pf.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180214180819.GE9919@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> This function takes two ptr/len pairs, which implies that
> they can be arbitrary buffers. But internally, it assumes
> that each "ptr" is NUL-terminated at "len" (because we
> memcpy an extra byte to pick up the NUL terminator).

Makes quite a lot of sense. In addition, get_value() assumes that the key cannot have NUL in it, so the use of counted string in alloc_test_entry() serves no purpose other than to confuse the readers ;-)

> Note that we can get rid of the "l1" and "l2" variables from
> cmd_main() as a further cleanup, since they are now mostly

Made me wonder if this "we can" is "we could if we wanted to in the future although we do not go that far in this patch", but it turns out that this is also done, and I think it is a good clean-up.

Previous: Jeff KingNext: Jeff King
Message 8 of 11 in “minor test-hashmap fixes”
  1. 0/6 minor test-hashmap fixesJeff King, Feb 14, 2018
  2. 1/6 test-hashmap: use ALLOC_ARRAY rather than bare mallocJeff King, Feb 14, 2018
  3. Code AIFeb 14, 2018
  4. 2/6 test-hashmap: check allocation computation for overflowJeff King, Feb 14, 2018
  5. 3/6 test-hashmap: use xsnprintf rather than snprintfJeff King, Feb 14, 2018
  6. 4/6 test-hashmap: use strbuf_getline rather than fgetsJeff King, Feb 14, 2018
  7. 5/6 test-hashmap: simplify alloc_test_entryJeff King, Feb 14, 2018
  8. Junio C HamanoFeb 14, 2018
  9. 6/6 test-hashmap: use "unsigned int" for hash storageJeff King, Feb 14, 2018
  10. Stefan BellerFeb 14, 2018
  11. Jeff KingFeb 14, 2018

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.