Merge pull request #1695 from rainers/issue_11528

fix issue 11528: crashes or undefined behaviour of appender's first allocation
This commit is contained in:
monarch dodra 2013-11-17 04:13:50 -08:00
commit ec5e25b796

View file

@ -2456,6 +2456,8 @@ struct Appender(A : T[], T)
//ret sugLen: A suggested growth.
private size_t appenderNewCapacity(size_t TSizeOf)(size_t curLen, size_t reqLen) @safe pure nothrow
{
if(curLen == 0)
return max(reqLen,8);
ulong mult = 100 + (1000UL) / (bsr(curLen * TSizeOf) + 1);
// limit to doubling the length, we don't want to grow too much
if(mult > 200)