xref: /PHP-8.2/ext/ffi/tests/037.phpt (revision bd9f4fa6)
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::new("int*[1]");
11    $buf[0] = $ptr;
12    //...
13    return $buf[0];
14}
15
16$int = FFI::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