xref: /PHP-8.4/ext/ffi/tests/037.phpt (revision 4acf0084)
1--TEST--
2FFI 037: Type memory management
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9function foo($ptr) {
10    $buf = FFI::cdef()->new("int*[1]");
11    $buf[0] = $ptr;
12    //...
13    return $buf[0];
14}
15
16$int = FFI::cdef()->new("int");
17$int->cdata = 42;
18var_dump(foo(FFI::addr($int)));
19?>
20--EXPECTF--
21object(FFI\CData:int32_t*)#%d (1) {
22  [0]=>
23  int(42)
24}
25