Permalink
Browse files

MemPtr.*: clean-up

  • Loading branch information...
1 parent f3095bb commit cc91c62c61bac3141d81035b879bed4a388bc842 @ghedo committed Feb 28, 2013
Showing with 12 additions and 22 deletions.
  1. +5 −5 lib/FFI/Raw/MemPtr.pm
  2. +7 −17 xs/MemPtr.xs
View
@@ -14,13 +14,13 @@ functions taking a C<FFI::Raw::ptr> argument.
=head1 METHODS
-=head2 new( $number )
+=head2 new( $length )
-Allocate a new C<FFI::Raw::MemPtr> of size C<$number> bytes.
+Allocate a new C<FFI::Raw::MemPtr> of size C<$length> bytes.
-=head2 new_from_buf( $buffer, $number )
+=head2 new_from_buf( $buffer, $length )
-Allocate a new C<FFI::Raw::MemPtr> of size C<$number> bytes and copy C<$buffer>
+Allocate a new C<FFI::Raw::MemPtr> of size C<$length> bytes and copy C<$buffer>
into it. This can be used, for example, to pass a pointer to a function that
takes a C struct pointer, by using C<pack()> or the L<Convert::Binary::C> module
to create the actual struct content.
@@ -53,7 +53,7 @@ It can be called using FFI::Raw as follows:
Which would print C<hello>.
-=head2 tostr( [$number] )
+=head2 tostr( [$length] )
Convert a C<FFI::Raw::MemPtr> to a Perl string.
View
@@ -1,34 +1,24 @@
MODULE = FFI::Raw PACKAGE = FFI::Raw::MemPtr
FFI_Raw_MemPtr_t *
-new(class, number)
+new(class, length)
SV *class
- unsigned int number
-
- INIT:
- void *temp;
+ unsigned int length
CODE:
- Newx(temp, number, char);
-
- RETVAL = temp;
+ Newx(RETVAL, length, char);
OUTPUT: RETVAL
FFI_Raw_MemPtr_t *
-new_from_buf(class, buffer, number)
+new_from_buf(class, buffer, length)
SV *class
SV *buffer
- unsigned int number
-
- INIT:
- void *temp;
+ unsigned int length
CODE:
- Newx(temp, number, char);
- Copy(SvPVX(buffer), temp, number, char);
-
- RETVAL = temp;
+ Newx(RETVAL, length, char);
+ Copy(SvPVX(buffer), RETVAL, length, char);
OUTPUT: RETVAL

0 comments on commit cc91c62

Please sign in to comment.