Re: [PATCH] alloc_ref(): allow for trailing NUL
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