Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer growth in AllocAppender #389

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion source/vibe/internal/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ struct AllocAppender(ArrayType : E[], E) {
reserve(new_size - m_data.length + m_remaining.length);
}

private auto withAlloc(string method, ARGS...)(ARGS args)
private auto withAlloc(string method, ARGS...)(auto ref ARGS args)
{
static if (is(RCIAllocator)) {
if (!m_rcAlloc.isNull) return __traits(getMember, m_rcAlloc, method)(args);
Expand Down Expand Up @@ -252,6 +252,14 @@ unittest {
assert(app.data == "foo");
}

unittest {
auto app = AllocAppender!string(theAllocator);
app.reserve(3);
app.put("foo");
app.put("bar");
assert(app.data == "foobar");
}


struct FixedAppender(ArrayType : E[], size_t NELEM, E) {
alias ElemType = Unqual!E;
Expand Down
Loading