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

Re: sha1_to_hex() usage cleanup

From
Junio C Hamano <junkio@cox.net>
Date
May 4, 2006, 00:36 UTC
Message-ID
<7v1wvabp7a.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0605031717190.4086@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 13 quoted lines
> Somebody on the #git channel complained that the sha1_to_hex() thing uses 
> a static buffer which caused an error message to show the same hex output 
> twice instead of showing two different ones.
>
> That's pretty easily rectified by making it uses a simple LRU of a few 
> buffers, which also allows some other users (that were aware of the buffer 
> re-use) to be written in a more straightforward manner.
>
> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
> ---
>
> This is another throw-away patch of mine. Not a big deal, but since I 
> tried it, I might as well try to submit it and see if Junio agrees..

Makes sort of sense in that the callers still need to be aware of the magic 4 limit but as long as they are they do not have to worry about allocation/deallocation/copying. But is that kind of cheat maintainable? I dunno.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 3 in “sha1_to_hex() usage cleanup”
  1. Linus TorvaldsMay 4, 2006
  2. Junio C HamanoMay 4, 2006
  3. Linus TorvaldsMay 4, 2006

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.