mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
Properly frees zvals in tests.
This commit is contained in:
5
types.go
5
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{} {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user