NAME
Task::MemManager::PerlAlloc - Allocates buffers using Perl's string functions
VERSION
version 0.02
SYNOPSIS
use Task::MemManager::PerlAlloc;
my $buffer = Task::MemManager::PerlAlloc::malloc(10, 1, 'A');
my $buffer_address = Task::MemManager::PerlAlloc::get_buffer_address($buffer);
Task::MemManager::PerlAlloc::free($buffer);
DESCRIPTION
This module provides a way to allocate buffers using Perl's string functions. The module is intended to be used in conjunction with the Task::MemManager
module, and thus it is probably best not to use these functions directly.
FUNCTIONS
malloc($num_of_items, $size_of_each_item, $init_value)
Allocates a buffer of size
$num_of_items * $size_of_each_item
bytes. If$init_value
is not defined, the buffer is not initialized. If$init_value
is the string 'zero', the buffer is zero initialized. Otherwise, the buffer is initialized with the value of$init_value
repeated for the entire buffer. The value returned is processed by theTask::MemManager
module in order to grab the memory address of the buffer just generated.free($buffer)
Frees the buffer allocated by
malloc
.get_buffer_address($buffer)
Returns the memory address of the buffer as a Perl scalar.
DIAGNOSTICS
There are no diagnostics that one can use. The module will croak if the allocation fails, so you don't have to worry about error handling.
DEPENDENCIES
This module depends on the Convert::Scalar
module to grow the buffer. The module depends on the Inline::C
module to access the memory buffer of the Perl scalar using the PerlAPI.
SEE ALSO
https://metacpan.org/pod/Convert::Scalar
This module exports various internal perl methods that change the internal representation or state of a perl scalar. All of these work in-place, that is, they modify their scalar argument.
https://metacpan.org/pod/Inline::C
Inline::C is a module that allows you to write Perl subroutines in C.
https://perldoc.perl.org/perlguts
Introduction to the Perl API.
https://perldoc.perl.org/perlapi
Autogenerated documentation for the perl public API.
AUTHOR
Christos Argyropoulos, <chrisarg at cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Christos Argyropoulos.
This is free software; you can redistribute it and/or modify it under the MIT license. The full text of the license can be found in the LICENSE file See https://en.wikipedia.org/wiki/MIT_License for more information.