diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 15:08:51 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 15:21:11 +0000 |
| commit | 8b6ba7222d9990bc19e355eabcf046a7ea773545 (patch) | |
| tree | adf98eaaebd455168806cdb6f5dbebb11fb3dd89 /lib/CodeGen/ArrayParameters.cc | |
| parent | fa83b7df5a0711bf5f4a5162cc33b0a4123a53c7 (diff) | |
fix(arrays): free array buffers when their scope ends
Register every array as a stack object so its buffer is freed on scope
end, re-DECLARE, RETURN and unwinding; run the element-destroy loop only
for types that need destruction.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ArrayParameters.cc')
| -rw-r--r-- | lib/CodeGen/ArrayParameters.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/CodeGen/ArrayParameters.cc b/lib/CodeGen/ArrayParameters.cc index 57dc523..319f1b5 100644 --- a/lib/CodeGen/ArrayParameters.cc +++ b/lib/CodeGen/ArrayParameters.cc @@ -27,8 +27,8 @@ void ArrayHandler::bindArrayParameter(const std::string &Name, Value *Ptr = DataPtr; if (MakeCopy) { // BYVAL: whole-buffer copy so callee writes stay invisible to the - // caller. The copy is malloc'd and never freed, consistent with the - // project-wide string policy. + // caller. The copy is malloc'd and registered below, so it is freed + // when the callee ends. Value *TotalBytes = Builder->CreateMul(TotalElements, Meta.ElementSizeC, Name + "_copy_bytes"); Value *Copy = Builder->CreateCall(MallocFunc, TotalBytes, Name + "_copy"); |
