/doc/core/: document zend_string APIs#21642
Open
LamentXU123 wants to merge 6 commits intophp:masterfrom
Open
Conversation
LamentXU123
commented
Apr 5, 2026
Contributor
Author
LamentXU123
left a comment
There was a problem hiding this comment.
Just commenting for easier reviewing
| - - Function/Macro [#persistent]_ | ||
| - Description | ||
|
|
||
| - - ``ZSTR_INIT(s, p)`` |
Contributor
Author
There was a problem hiding this comment.
I think the original doc is wrong. This should be ZSTR_INIT_LITERAL. Is it?
| - Same as ``zend_string_concat2``, but for three character buffers. | ||
|
|
||
| - - ``ZSTR_EMPTY_ALLOC()`` | ||
| - Gets an immutable, empty string. This does not allocate memory. |
Contributor
Author
There was a problem hiding this comment.
Return would be better in case of Get in functions
| - Decreases the reference count and frees the string if it goes to 0. | ||
|
|
||
| - - ``zend_string_dup(s, p)`` | ||
| - Creates a true copy of the string in a new allocation, except if the string is interned. |
Contributor
Author
There was a problem hiding this comment.
How does this function related to reference counting? Shouldn't it be in the "create/allocate" section?
|
|
||
| - - ``ZSTR_HASH`` | ||
| - ``Z_STRHASH[_P]`` | ||
| - Computes the string has if it hasn't already been, and returns it. |
Contributor
Author
There was a problem hiding this comment.
not sure if this fix is right, but the original one is wrong.
| API | ||
| ***** | ||
|
|
||
| The string API is defined in ``Zend/zend_string.h``. It provides a number of functions for creating |
Contributor
Author
There was a problem hiding this comment.
It do provide other functions except just for creating new strings?
| hashing, and interning helpers. | ||
|
|
||
| .. list-table:: ``zend_string`` creation | ||
| .. list-table:: Creation and allocation APIs |
Contributor
Author
There was a problem hiding this comment.
Just to make things more accurate here
alecpl
reviewed
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR added (and also fixed) some internal APIs concerning zend_string, cc @iluuu1994 as we privately talk about the doc work before.