-
Notifications
You must be signed in to change notification settings - Fork 602
perlapi: Reword savepv entry #23720
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
perlapi: Reword savepv entry #23720
Conversation
inline.h
Outdated
| 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)>. |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PerlMemShared_free() is undocumented
There was a problem hiding this comment.
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_*.
ce7c9ae to
19000c8
Compare
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. |
There was a problem hiding this comment.
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<...>?
There was a problem hiding this comment.
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.
19000c8 to
05fa52f
Compare
I think this makes it clearer