Skip to content

Conversation

@khwilliamson
Copy link
Contributor

I think this makes it clearer

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

inline.h Outdated
Comment on lines 4668 to 4670
To prevent memory leaks, the memory allocated for the new string needs to be
freed when no longer needed. This can be done with the C<L</Safefree>>
function, or L<C<SAVEFREEPV>|perlguts/SAVEFREEPV(p)>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Memory allocated by the shared variants needs to be freed by PerlMemShared_free(). There doesn't appear to be a share variant of SAVEFREEPV() (they're probably always owned by something like an OP or PADNAME that's responsible for releasing them)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PerlMemShared_free() is undocumented

Copy link
Contributor

Choose a reason for hiding this comment

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

That appears to be true for all of the system call wrappers, anything PerlLIO_*(), PerlSock_*(), PerlProc_*(), PerlMem(Shared|Parse|)*() (nothing uses the Parse variants), PerlSIO_*, PerlDir_*.

@khwilliamson khwilliamson force-pushed the savepv branch 2 times, most recently from ce7c9ae to 19000c8 Compare September 18, 2025 01:55
inline.h Outdated
In the case of C<savepv>, the size of the string is determined by C<strlen()>,
which means it may not contain embedded C<NUL> characters, and must have a
trailing C<NUL>.
Use the C</PerlMemShared_free> function.
Copy link
Contributor

Choose a reason for hiding this comment

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

Stray / in this C<...> I think? Or maybe you intended to use L<...>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, as always. I started to make a link, then realized that PerlMemShared_free is undocumented.

Patches welcome

Shared memory must be freed by a different (undocumented) function than
non-shared.  This wasn't mentioned before this commit.
@khwilliamson khwilliamson merged commit 6ddb6d7 into Perl:blead Sep 22, 2025
33 checks passed
@khwilliamson khwilliamson deleted the savepv branch September 22, 2025 01:04
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.

3 participants