1--TEST-- 2FFI 036: Type memory management 3--EXTENSIONS-- 4ffi 5--INI-- 6ffi.enable=1 7--FILE-- 8<?php 9$type = FFI::type("int*"); 10 11function foo($ptr) { 12 global $type; 13 //$buf = FFI::new("int*[1]"); /* this loses type and crash */ 14 $buf = FFI::new(FFI::arrayType($type, [1])); 15 $buf[0] = $ptr; 16 //... 17 return $buf[0]; 18} 19 20$int = FFI::new("int"); 21$int->cdata = 42; 22var_dump(foo(FFI::addr($int))); 23?> 24--EXPECTF-- 25object(FFI\CData:int32_t*)#%d (1) { 26 [0]=> 27 int(42) 28} 29