File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
dist/ExtUtils-ParseXS/lib Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff 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
33403343XSUB 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
You can’t perform that action at this time.
0 commit comments