aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimenus <ryan.saunderson88@gmail.com>2021-03-22 13:16:12 -0500
committerAndrew Kelley <andrew@ziglang.org>2021-03-22 11:58:44 -0700
commit240b15381dd560cac004c5e84783fb93f03c0697 (patch)
treeefcf256d306ac0b5235b701f28b2695814f81eb9 /src
parentf3770dcc307e4207de8e38c44bcf1bf98dc8448c (diff)
downloadzig-240b15381dd560cac004c5e84783fb93f03c0697.tar.gz
zig-240b15381dd560cac004c5e84783fb93f03c0697.zip
fix calculation in ensureCapacity
Diffstat (limited to 'src')
-rw-r--r--src/Module.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 5fcdd8c6f1..cb41c1de6a 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -2531,7 +2531,8 @@ fn astgenAndSemaFn(
// `extra` so that we have access to the data in codegen, for debug info.
const str_index = @intCast(u32, wip_zir_code.string_bytes.items.len);
wip_zir_code.extra.appendAssumeCapacity(str_index);
- try wip_zir_code.string_bytes.ensureCapacity(mod.gpa, param_name.len + 1);
+ const used_bytes = wip_zir_code.string_bytes.items.len;
+ try wip_zir_code.string_bytes.ensureCapacity(mod.gpa, used_bytes + param_name.len + 1);
wip_zir_code.string_bytes.appendSliceAssumeCapacity(param_name);
wip_zir_code.string_bytes.appendAssumeCapacity(0);
}