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

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

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

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


-- 
·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