addr example

$abi callable(int32_t, char*): void { returnType: FFI\CType<void> size 1 align 1 {} } PHP, \FFI::cdef()->new('void (*)(int a, const char* b)'));
    }

    public function testCastNonCuttedPointerToChar()
    {
        $actualMessage = "Hello World!\0";

        $string = \FFI::cdef()->new('char[100]');
        $pointer = \FFI::addr($string[0]);
        \FFI::memcpy($pointer$actualMessage, \strlen($actualMessage));

        $this->assertDumpEquals(<<<'PHP' FFI\CData<char*> size 8 align 8 { cdata: "Hello World!\x00" } PHP, $pointer);
    }

    public function testCastCuttedPointerToChar()
    {
        
Home | Imprint | This part of the site doesn't use cookies.