Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do_print: Use new utf8_to_bytes_temp_pv() #22812

Open
wants to merge 2 commits into
base: blead
Choose a base branch
from

Conversation

khwilliamson
Copy link
Contributor

  • This set of changes does not require a perldelta entry.

@khwilliamson khwilliamson changed the title do_print: Use new utfj8_to_bytes_temp_pv() do_print: Use new utf8_to_bytes_temp_pv() Dec 3, 2024
doio.c Show resolved Hide resolved
doio.c Outdated Show resolved Hide resolved
embed.fnc Outdated Show resolved Hide resolved
doio.c Outdated Show resolved Hide resolved
doio.c Outdated
@@ -2259,7 +2260,7 @@ Perl_do_print(pTHX_ SV *sv, PerlIO *fp)
* but only until the system hard limit/the filesystem limit,
* at which we would get EPERM. Note that when using buffered
* io the write failure can be delayed until the flush/close. --jhi */
if (len && (PerlIO_write(fp,tmps,len) == 0))
if (len && (PerlIO_write(fp,(char *) tmps,len) == 0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PerlIO_write() takes a const void * for the buffer, you don't need the cast.

Copy link
Contributor

@tonycoz tonycoz Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still the case, no cast is required

doio.c Outdated Show resolved Hide resolved
khwilliamson added a commit to khwilliamson/perl5 that referenced this pull request Jan 12, 2025
Two new functions were recently added that have a *free_me parameter.
As Tony Cook pointed out in Perl#22812, these would better have been void*
instead of U8*.  This commit changes to use void*

One function in pp.c was using this parameter as a U8* and using its
contents.  But this need goes away with the new bytes_to_utf8_free_me()
function, which eliminates the kludge pp.c used to make sure the new
memory got freed.
This removes 6 casts and adds 2, resulting in cleaner looking code.
These new functions do the work this used to duplicate, except they
allocate memory only if necessary, instead of always, as previously
khwilliamson added a commit to khwilliamson/perl5 that referenced this pull request Jan 21, 2025
Two new functions were recently added that have a *free_me parameter.
As Tony Cook pointed out in Perl#22812, these would better have been void*
instead of U8*.  This commit changes to use void*

One function in pp.c was using this parameter as a U8* and using its
contents.  But this need goes away with the new bytes_to_utf8_free_me()
function, which eliminates the kludge pp.c used to make sure the new
memory got freed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants