FFI::Platypus::Type::PointerSizeBuffer3pm
Convert string scalar to a buffer as a pointer / size_t combination
Usage
In your C code:
voidfunction_with_buffer(void *pointer, size_t size){...}
In your Platypus::FFI code:
use FFI::Platypus 2.00;my $ffi = FFI::Platypus->new( api => 2 );$ffi->load_custom_type('::PointerSizeBuffer' => 'buffer');$ffi->attach(function_with_buffer => ['buffer'] => 'void');my $string = "content of buffer";function_with_buffer($string);
Version
version 2.10
Overview
A common pattern in C code is to pass in a region of memory as a buffer, consisting of a pointer and a size of the memory region. In Perl, string scalars also point to a contiguous series of bytes that has a size, so when interfacing with C libraries it is handy to be able to pass in a string scalar as a pointer / size buffer pair.
Copyright and license
This software is copyright (c) 2015-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Releases
5 releases since Debian 9 (Stretch); the text changed 4 times.