NAME
Judy::Mem - Useful functions for interacting with memory
DATA TYPES
$Ptr - pointer
$String - perl string
$Length - integer
FUNCTIONS
$Ptr = String2Ptr( $String )
Copies $String
into a new C string. The allocated string will be large enough to hold your perl string regardless of whether it uses multi-byte characters, or has null characters.
You'll need to be careful to free this copy later when you're done with it.
$String = Ptr2String( $Ptr )
Dereferences $Ptr
and copies it into a new perl string. Doesn't do anything about Unicode, multibyte encoding, or null characters. In fact, if you have nulls in your data, your copied string will be truncated. Use the other function Ptr2String2
which allows you to pass in the byte length.
$String = Ptr2String2( $Ptr, $Length )
Dereferences $Ptr
and copies it into a new perl string. Doesn't do anything about Unicode, multibyte encoding. See the Encode and utf8 about flipping the Perl utf8 bits.
Free( $Ptr )
Frees a pointer. You should be using this function on any pointer you previously allocated with String2Ptr or String2Ptr2.
$Int = Peek( $Ptr )
Reads an integer out of memory. This is equivalent to:
(Word_t)*ptr
Poke( $Ptr, $Int )
Writes an integer to memory. This is equivalent to to C code:
*ptr = (Word_t)val;
ERRORS & WARNINGS
See Judy.
AUTHOR
See Judy.