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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpaVIVl4kclY.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux