D-Programming-Language/phobos — pull request #2046 by monarchdodra (2014-03-24 12:33:31+00:00)
Title: Fix "use up capacity" in Appender

Fix 2 of about 4-5 in `Appender`.

This one makes it so that Appender *actually* uses up capacity. The previous code didn't actually *do* anything, meaning data created by Appender could accidentally be clobbered by others.

```D
string s = "hello".idup;
auto app = appender!string(s);
put(app, 'w');
s ~= 'a'; //Clobbers here
assert(app.data == "hellow"); //Fails
```

Unfortunately, yes, this will initialize memory. The only way around this that I know of is to either use `assumeSafeAppend`, which currently isn't pure. Or to do nothing, and not "use up capacity". Either way, the code is broken, and needs fixing.

This contains a bit of conflict with my other pull. That's my problem. Let's just pull whichever one gets reviewed first.