<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">That looks good to me unless anyone has any objections. I assume it passes "make test."<div><br><div><div>On Sep 15, 2008, at 10:17 PM, Zhongxing Xu wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">May I commit the patch:<br><br>Index: lib/Rewrite/RewriteRope.cpp<br>===================================================================<br>--- lib/Rewrite/RewriteRope.cpp (revision 56235)<br>+++ lib/Rewrite/RewriteRope.cpp (working copy)<br> @@ -792,7 +792,7 @@<br> if (AllocBuffer && --AllocBuffer->RefCount == 0)<br> delete [] (char*)AllocBuffer;<br><br>- unsigned AllocSize = sizeof(RopeRefCountString)-1+AllocChunkSize;<br>+ unsigned AllocSize = offsetof(RopeRefCountString, Data) + AllocChunkSize;<br> AllocBuffer = reinterpret_cast<RopeRefCountString *>(new char[AllocSize]);<br> AllocBuffer->RefCount = 0;<br> memcpy(AllocBuffer->Data, Start, Len);<br><br><br><div class="gmail_quote">2008/9/16 Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span><br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br> On Sep 15, 2008, at 9:41 PM, Daniel Dunbar wrote:<br> <br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> #include <stddef.h><br> <br> unsigned AllocSize = sizeof(RopeRefCountString) -<br> offsetof(RopeRefCountString,Data) + AllocChunkSize;<br> </blockquote> <br></div> I don't think that's right. sizeof(RopeRefCountString) - offsetof(RopeRefCountString,Data) is 4. What we want is the number of bytes before "data", not after (inclusive).<br> <br> Probably:<br> <br> offsetof(RopeRefCountString,Data) + AllocChunkSize<br> <br> <br> </blockquote></div><br></div></blockquote></div><br></div></body></html>