FFI::P...Buffer(3pm)

πŸ’… NAME πŸ’…

okay so this page is the User Contributed Perl Documentation entry for FFI::P...Buffer(3pm), and the full module name is FFI::Platypus::Type::PointerSizeBuffer. its whole slay is to Convert string scalar to a buffer as a pointer / size_t combination. that's the assignment, bestie πŸ¦‹

⭐ VERSION ⭐

version 2.11 β€” that's the version, no cap πŸ’€

πŸŽ€ SYNOPSIS πŸŽ€

In your C code:

void
function_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);

πŸ’– DESCRIPTION πŸ’–

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. that's literally the C flex: pointer + size, holding hands 🫢

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. this type is the little matchmaker that lets that happen πŸ’–

πŸ”₯ SEE ALSO πŸ”₯

  • FFI::Platypus β€” Main Platypus documentation. πŸ‘‘
  • FFI::Platypus::Type β€” Platypus types documentation. ✨

πŸ‘‘ AUTHOR πŸ‘‘

Author: Graham Ollis <plicease@cpan.org> 🌟

Contributors:

  • Bakkiaraj Murugesan (bakkiaraj)
  • Dylan Cali (calid)
  • pipcet
  • Zaki Mughal (zmughal)
  • Fitz Elliott (felliott)
  • Vickenty Fesunov (vyf)
  • Gregor Herrmann (gregoa)
  • Shlomi Fish (shlomif)
  • Damyan Ivanov
  • Ilya Pavlov (Ilya33)
  • Petr PΓ­saΕ™ (ppisar)
  • Mohammad S Anwar (MANWAR)
  • HΓ₯kon HΓ¦gland (hakonhagland, HAKONH)
  • Meredith (merrilymeredith, MHOWARD)
  • Diab Jerius (DJERIUS)
  • Eric Brine (IKEGAMI)
  • szTheory
  • JosΓ© JoaquΓ­n Atria (JJATRIA)
  • Pete Houston (openstrike, HOUSTON)
  • Lukas Mai (MAUKE)

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.


okay that's the whole page, bestie πŸ’– β€” with love from perl v5.42.3, dated 2026-08-20, page FFI::P...Buffer(3pm) 🫢

πŸ“¦ where this page comes from