<div dir="ltr"><br><br><div class="gmail_quote">2008/9/16 Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@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">On Sep 15, 2008, at 2:40 PM, Ted Kremenek wrote:<br>
</div><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">
On Sep 7, 2008, at 1:32 AM, Zhongxing Xu wrote:<br>
</div><div><div></div><div class="Wj3C7c"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In RewriteRope.cpp, RewriteRope::MakeRopeString(const char *Start,<br>
const char *End),<br>
we calculate the AllocSize by:<br>
<br>
unsigned AllocSize = sizeof(RopeRefCountString) - 1 + AllocChunkSize;<br>
<br>
I guess here the intention is: sizeof(RopeRefCountString) is 5. But<br>
gcc says sizeof(RopeRefCountString) is 8. So the actual AllocSize is<br>
4087. Should we minus 4 instead of 1 to make the AllocSize 4084?<br>
</blockquote>
<br>
The "-1" I believe is to accommodate for the field Data[1], which<br>
occupies a single byte:<br>
<br>
  struct RopeRefCountString {<br>
    unsigned RefCount;<br>
    char Data[1];  //  Variable sized.<br>
<br>
    void addRef() { ... }<br>
    void dropRef() { ... }<br>
  };<br>
<br>
By subtracting 1, the field "Data" refers to an array with size<br>
AllocChunkSize.<br>
</div></div></blockquote>
<br>
That was the intention, but it forgot the tail padding, so this is a real 'bug'.  The intention was the make the allocation just under a page in size.  Is this causing a problem in practice?</blockquote><div><br>
No, it's not causing any problem in practice. <br></div></div><br></div>