From 4e22f464387725a5a282f3d72e11cfb694a31a5a Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 05:33:33 +0000 Subject: feat(memory): add checked REALLOC with failure preservation Co-Authored-By: Claude Fable 5.1 --- lib/CodeGen/ExpressionGen.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/CodeGen/ExpressionGen.cc') diff --git a/lib/CodeGen/ExpressionGen.cc b/lib/CodeGen/ExpressionGen.cc index 0a24c8d..9ea79d8 100644 --- a/lib/CodeGen/ExpressionGen.cc +++ b/lib/CodeGen/ExpressionGen.cc @@ -192,6 +192,13 @@ Value *CodeGen::emitCall(const std::string &Callee, if (!Size) return nullptr; return Memory->emitAllocate(Size, Line); } + if (Name == "REALLOC") { + Value *Address = emitCoercedExpr(ArgExprs[0].get(), resolveType("C_TYPE(\"void*\")")); + if (!Address) return nullptr; + Value *Size = emitAllocationSize(ArgExprs[1].get()); + if (!Size) return nullptr; + return Memory->emitResize(Address, Size, Line); + } if (Name == "FREE") { Value *Address = emitCoercedExpr(ArgExprs[0].get(), resolveType("C_TYPE(\"void*\")")); if (!Address) return nullptr; -- cgit v1.3.1-4-g156e