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

Re: [PATCH] alloc_ref(): allow for trailing NUL

From
Pierre Habouzit <madcoder@debian.org>
Date
Sep 28, 2007, 13:13 UTC
Message-ID
<20070928131348.GB21309@artemis.corp>
In-Reply-To
<20070928124102.GA21309@artemis.corp>
On Fri, Sep 28, 2007 at 12:41:02PM +0000, Pierre Habouzit wrote:
Show 14 quoted lines
> 	void *xflexdupz(size_t offset, void *src, size_t len)
> 	{
> 		char *p = xmalloc(offset + len + 1);
> 		memset(p, 0, offset);
> 		memcpy(p + offset, src, len);
> 		p[offset + len] = '\0';
> 		return p;
> 	}
> 
>   Then alloc_ref could be a wrapper around:
>   xflexdupz(offsetof(struct ref, name), ..., ...).
> 
>   Of course right now alloc_ref doesn't perform any kind of copy, but a
> grep -A1 will convince you that it's not a problem:
  [...]
> 	remote.c:		ret = alloc_ref(strlen(name) + 6);
> 	remote.c-		sprintf(ret->name, "refs/%s", name);
  okay forget about me, my proposal doesn't work, too bad :)
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Pierre HabouzitNext: Daniel Barkalow
Message 6 of 9 in “alloc_ref(): allow for trailing NUL”
  1. alloc_ref(): allow for trailing NULJohannes Schindelin, Sep 28, 2007
  2. Daniel BarkalowSep 28, 2007
  3. Junio C HamanoSep 28, 2007
  4. Johannes SchindelinSep 28, 2007
  5. Pierre HabouzitSep 28, 2007
  6. Pierre HabouzitSep 28, 2007
  7. Daniel BarkalowSep 28, 2007
  8. Johannes SchindelinSep 28, 2007
  9. Junio C HamanoSep 28, 2007

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.