Skip to content

/doc/core/: document zend_string APIs#21642

Open
LamentXU123 wants to merge 6 commits intophp:masterfrom
LamentXU123:doc-1
Open

/doc/core/: document zend_string APIs#21642
LamentXU123 wants to merge 6 commits intophp:masterfrom
LamentXU123:doc-1

Conversation

@LamentXU123
Copy link
Copy Markdown
Contributor

@LamentXU123 LamentXU123 commented Apr 5, 2026

This PR added (and also fixed) some internal APIs concerning zend_string, cc @iluuu1994 as we privately talk about the doc work before.

Copy link
Copy Markdown
Contributor Author

@LamentXU123 LamentXU123 left a comment

Choose a reason for hiding this comment

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

Just commenting for easier reviewing

- - Function/Macro [#persistent]_
- Description

- - ``ZSTR_INIT(s, p)``
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor Author

@LamentXU123 LamentXU123 Apr 5, 2026

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor Author

@LamentXU123 LamentXU123 Apr 5, 2026

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just to make things more accurate here

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