From a222fd51cbe9df771a66f858063a9cd71ad577f5 Mon Sep 17 00:00:00 2001 From: Alliballibaba Date: Fri, 19 Dec 2025 23:01:58 +0100 Subject: [PATCH] Properly frees zvals in tests. --- types.go | 5 +++++ types_test.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/types.go b/types.go index 784bc17f..c47f1538 100644 --- a/types.go +++ b/types.go @@ -538,6 +538,11 @@ func zendArrayRelease(p unsafe.Pointer) { C.zend_array_release((*C.zend_array)(p)) } +// used in tests for cleanup +func efree(p unsafe.Pointer) { + C.__efree__(p) +} + // EXPERIMENTAL: CallPHPCallable executes a PHP callable with the given parameters. // Returns the result of the callable as a Go interface{}, or nil if the call failed. func CallPHPCallable(cb unsafe.Pointer, params []interface{}) interface{} { diff --git a/types_test.go b/types_test.go index f5e33537..41df2530 100644 --- a/types_test.go +++ b/types_test.go @@ -169,6 +169,7 @@ func BenchmarkBool(b *testing.B) { benchOnPHPThread(b, b.N, func() { phpBool := PHPValue(true) _, _ = GoValue[bool](phpBool) + efree(phpBool) }) } @@ -176,6 +177,7 @@ func BenchmarkInt(b *testing.B) { benchOnPHPThread(b, b.N, func() { phpInt := PHPValue(int64(42)) _, _ = GoValue[int64](phpInt) + efree(phpInt) }) } @@ -183,6 +185,7 @@ func BenchmarkFloat(b *testing.B) { benchOnPHPThread(b, b.N, func() { phpFloat := PHPValue(3.14) _, _ = GoValue[float64](phpFloat) + efree(phpFloat) }) }