Re: [RFC] strbuf's in builtin-apply

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

 



On Sat, Sep 15, 2007 at 02:12:10PM +0000, Pierre Habouzit wrote:
> +		nsize = buf->len;
> +		nbuf = convert_to_git(path, buf->buf, &nsize);
> +		if (nbuf)
> +			strbuf_embed(buf, nbuf, nsize, nsize);

  Okay, I managed to be able to be sure that convert_to_git always have
an extra ending NUL byte, with an intermediate patch.  So now I call
strbuf_embed with nsize, nsize + 1 which has negligible cost.

  Though this question remains:

>   Another suspicious hunk is:
> 
> -	data = (void*) fragment->patch;
> [...]
>  	case BINARY_LITERAL_DEFLATED:
> -		free(desc->buffer);
> -		desc->buffer = data;
> -		dst_size = fragment->size;
> -		break;
> +		strbuf_embed(buf, fragment->patch, fragment->size, fragment->size);
> +		return 0;
> 
>   TTBOMK the ->patch pointer is a pointer inside a buffer, not a buffer
> that has been malloc'ed (and there are code paths before my patch that
> would still realloc the buffer so I don't think I introduce an issue).
> It passes the test-suite without crashing, but well, maybe this should
> be a copy instead.
> 
>   The rest is pretty straightforward.
> 
> -- 
> ·O·  Pierre Habouzit
> ··O                                                madcoder@xxxxxxxxxx
> OOO                                                http://www.madism.org



-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpG0hATK7x3p.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