Skip to content

Commit b54a5b4

Browse files
committed
mention explicitly-manage for const char * arguments
1 parent 679c478 commit b54a5b4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Language/nativecall.pod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ routine itself.
8585
Note that a null string can be passed by passing the Str type object; a null
8686
return will also be represented by the type object.
8787
88+
For string arguments that are specified as C<const char *> it is necessary
89+
to tell Perl not to free the memory allocated to the C string after the
90+
function returns using C<explicity-manage> :
91+
92+
# C prototype is set_foo(const char * foo)
93+
sub set_foo(Str) is native('libfoo') { * }
94+
my $string = "FOO";
95+
explicitly-manage($string);
96+
set_foo($string);
97+
8898
=head1 Basic use of Pointers
8999
90100
Sometimes you need to get a pointer (for example, a library handle) back from a

0 commit comments

Comments
 (0)