File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -2865,9 +2865,24 @@ automatically freed, via a call to C<L</SAVEFREEPV>>.
2865
2865
2866
2866
For C<utf8_to_bytes_new_pv>, C<*free_me> has been set to C<*s_ptr>, and it is
2867
2867
the caller's responsibility to free the new memory when done using it.
2868
- The results of this parameter can simply be passed to C<L</Safefree>> when
2869
- done, as that handles a C<NULL> parameter, and/or it can be used as a boolean
2870
- (non-NULL meaning C<true>) to indicate that the input was indeed changed.
2868
+ The following paradigm is convenient to use for this:
2869
+
2870
+ void * free_me;
2871
+ if (utf8_to_bytes_new_pv(&s, &len, &free_me) {
2872
+ ...
2873
+ }
2874
+ else {
2875
+ ...
2876
+ }
2877
+
2878
+ ...
2879
+
2880
+ Safefree(free_me);
2881
+
2882
+ C<free_me> can be used as a boolean (non-NULL meaning C<true>) to indicate that
2883
+ the input was indeed changed if you need to revisit that later in the code.
2884
+ Your design is likely flawed if you find yourself using C<free_me> for any
2885
+ other purpose.
2871
2886
2872
2887
=back
2873
2888
You can’t perform that action at this time.
0 commit comments