File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,21 @@ For string arguments that are specified as C<const char *> it is necessary
97
97
to tell Perl not to free the memory allocated to the C string after the
98
98
function returns using C < explicitly-manage > :
99
99
100
- # C prototype is set_foo(const char * foo)
100
+ # C prototype is void set_foo(const char * foo)
101
101
sub set_foo(Str) is native('foo') { * }
102
102
my $string = "FOO";
103
103
explicitly-manage($string);
104
104
set_foo($string);
105
105
106
106
= head1 Basic use of Pointers
107
107
108
+ When the signature of your native function needs a pointer to some native type
109
+ (int, uint, etc.) all you need to do is declare the argument C < is rw > :
110
+
111
+ # C prototype is void my_version(int *mayor, int *minor)
112
+ sub my_version(int32 is rw, int32 is rw) is native('foo') { * }
113
+ my_version(my int32 $mayor, my int32 $minor); # Pass a pointer to
114
+
108
115
Sometimes you need to get a pointer (for example, a library handle) back from a
109
116
C library. You don't care about what it points to - you just need to keep hold
110
117
of it. The Pointer type provides for this.
You can’t perform that action at this time.
0 commit comments