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