Properly frees zvals in tests.

This commit is contained in:
Alliballibaba
2025-12-19 23:01:58 +01:00
parent e2976abbeb
commit a222fd51cb
2 changed files with 8 additions and 0 deletions

View File

@@ -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{} {

View File

@@ -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)
})
}