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 1.10
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( api => 1 );
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
75 Håkon Hægland (hakonhagland, HAKONH)
76
77 Meredith (merrilymeredith, MHOWARD)
78
79 Diab Jerius (DJERIUS)
80
82 This software is copyright (c) 2015,2016,2017,2018,2019 by Graham
83 Ollis.
84
85 This is free software; you can redistribute it and/or modify it under
86 the same terms as the Perl 5 programming language system itself.
87
88
89
90perl v5.30.1 2020F-F0I2:-:0P6latypus::Type::PointerSizeBuffer(3)