Skip to content

Commit 08a1224

Browse files
committed
perlxs.pod: update: cleanup part
Add text to the new =head2 The XSUB Cleanup Part section, and rewrite the text in this existing section: =head3 The CLEANUP: Keyword
1 parent 6264856 commit 08a1224

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

dist/ExtUtils-ParseXS/lib/perlxs.pod

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,18 +3334,31 @@ values are returned.
33343334

33353335
=head2 The XSUB Cleanup Part
33363336

3337-
XXX TBC
3337+
Following an XSUB's output part, where code will have been planted to
3338+
return the value of C<RETVAL> and C<OUT>/C<OUTLIST> parameters, it's
3339+
possible to inject some final clean-up code by using the C<CLEANUP>
3340+
keyword.
33383341

3339-
XXX NB: the keywords described in L<XSUB Generic Keywords> and L<Sharing
3342+
Note that the keywords described in L<XSUB Generic Keywords> and L<Sharing
33403343
XSUB bodies> may also appear in this part.
33413344

33423345
=head3 The CLEANUP: Keyword
33433346

3344-
This keyword can be used when an XSUB requires special cleanup procedures
3345-
before it terminates. When the CLEANUP: keyword is used it must follow
3346-
any CODE:, or OUTPUT: blocks which are present in the XSUB. The code
3347-
specified for the cleanup block will be added as the last statements in
3348-
the XSUB.
3347+
char *
3348+
foo(int a)
3349+
CODE:
3350+
RETVAL = get_foo(a);
3351+
OUTPUT:
3352+
RETVAL
3353+
CLEANUP:
3354+
free(RETVAL); /* assuming get_foo() returns a malloced buffer */
3355+
3356+
The C<CLEANUP> keyword allows a block of code to be inserted directly
3357+
after any output code which has been generated automatically or via the
3358+
C<OUTPUT> keyword. It can be used when an XSUB requires special clean-up
3359+
procedures before it terminates. The code specified for the clean-up block
3360+
will be added as the last statements in the XSUB before the final
3361+
C<XSRETURN(1);> or similar.
33493362

33503363
=head2 XSUB Generic Keywords
33513364

0 commit comments

Comments
 (0)