Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update nativecall.pod
Describe how to pass allocated pointers to native types in native calls
  • Loading branch information
salortiz committed Feb 10, 2016
1 parent c08878c commit 1601312
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doc/Language/nativecall.pod
Expand Up @@ -97,14 +97,21 @@ For string arguments that are specified as C<const char *> it is necessary
to tell Perl not to free the memory allocated to the C string after the
function returns using C<explicitly-manage> :
# C prototype is set_foo(const char * foo)
# C prototype is void set_foo(const char * foo)
sub set_foo(Str) is native('foo') { * }
my $string = "FOO";
explicitly-manage($string);
set_foo($string);
=head1 Basic use of Pointers
When the signature of your native function needs a pointer to some native type
(int, uint, etc.) all you need to do is declare the argument C<is rw> :
# C prototype is void my_version(int *mayor, int *minor)
sub my_version(int32 is rw, int32 is rw) is native('foo') { * }
my_version(my int32 $mayor, my int32 $minor); # Pass a pointer to
Sometimes you need to get a pointer (for example, a library handle) back from a
C library. You don't care about what it points to - you just need to keep hold
of it. The Pointer type provides for this.
Expand Down

0 comments on commit 1601312

Please sign in to comment.