1FFI::Platypus::Type::PoUisnetrerCSoinzterBiubfufteerdF(F3PI)e:r:lPlDaotcyupmuesn:t:aTtyipoen::PointerSizeBuffer(3)
2
3
4
6 FFI::Platypus::Type::PointerSizeBuffer - Convert string scalar to a
7 buffer as a pointer / size_t combination
8
10 version 0.94
11
13 In your C code:
14
15 void
16 function_with_buffer(void *pointer, size_t size)
17 {
18 ...
19 }
20
21 In your Platypus::FFI code:
22
23 use FFI::Platypus;
24
25 my $ffi = FFI::Platypus->new;
26 $ffi->load_custom_type('::PointerSizeBuffer' => 'buffer');
27
28 $ffi->attach(function_with_buffer => ['buffer'] => 'void');
29 my $string = "content of buffer";
30 function_with_buffer($string);
31
33 A common pattern in C code is to pass in a region of memory as a
34 buffer, consisting of a pointer and a size of the memory region. In
35 Perl, string scalars also point to a contiguous series of bytes that
36 has a size, so when interfacing with C libraries it is handy to be able
37 to pass in a string scalar as a pointer / size buffer pair.
38
40 FFI::Platypus
41 Main Platypus documentation.
42
43 FFI::Platypus::Type
44 Platypus types documentation.
45
47 Author: Graham Ollis <plicease@cpan.org>
48
49 Contributors:
50
51 Bakkiaraj Murugesan (bakkiaraj)
52
53 Dylan Cali (calid)
54
55 pipcet
56
57 Zaki Mughal (zmughal)
58
59 Fitz Elliott (felliott)
60
61 Vickenty Fesunov (vyf)
62
63 Gregor Herrmann (gregoa)
64
65 Shlomi Fish (shlomif)
66
67 Damyan Ivanov
68
69 Ilya Pavlov (Ilya33)
70
71 Petr Pisar (ppisar)
72
73 Mohammad S Anwar (MANWAR)
74
76 This software is copyright (c) 2015,2016,2017,2018,2019 by Graham
77 Ollis.
78
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81
82
83
84perl v5.30.0 2019F-F0I7:-:2P6latypus::Type::PointerSizeBuffer(3)