Thread (6 messages) flat view 6 messages, 4 authors, 2016-06-15

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

From: Pierre Habouzit <hidden>
Date: 2016-06-15 22:43:37

Possibly related (same subject, not in this thread)

On Fri, Sep 28, 2007 at 12:41:02PM +0000, Pierre Habouzit wrote:
	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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help