mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
bd9f4fa676
For rationale, see https://github.com/php/php-src/pull/6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
29 lines
476 B
PHP
29 lines
476 B
PHP
--TEST--
|
|
FFI 036: Type memory management
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
$type = FFI::type("int*");
|
|
|
|
function foo($ptr) {
|
|
global $type;
|
|
//$buf = FFI::new("int*[1]"); /* this loses type and crash */
|
|
$buf = FFI::new(FFI::arrayType($type, [1]));
|
|
$buf[0] = $ptr;
|
|
//...
|
|
return $buf[0];
|
|
}
|
|
|
|
$int = FFI::new("int");
|
|
$int->cdata = 42;
|
|
var_dump(foo(FFI::addr($int)));
|
|
?>
|
|
--EXPECTF--
|
|
object(FFI\CData:int32_t*)#%d (1) {
|
|
[0]=>
|
|
int(42)
|
|
}
|