/doc/core/: document zend_string APIs#21642
Conversation
LamentXU123
left a comment
There was a problem hiding this comment.
Just commenting for easier reviewing
| - - Function/Macro [#persistent]_ | ||
| - Description | ||
|
|
||
| - - ``ZSTR_INIT(s, p)`` |
There was a problem hiding this comment.
I think the original doc is wrong. This should be ZSTR_INIT_LITERAL. Is it?
| - - ``zend_string_concat2(s1, l1, s2, l2)`` | ||
| - Creates a non-persistent string by concatenating two character buffers. | ||
|
|
||
| - - ``zend_string_concat3(...)`` |
There was a problem hiding this comment.
I write the entire arguments out, since other functions in the doc has an even longer list of arguments
| - Same as ``zend_string_concat2``, but for three character buffers. | ||
|
|
||
| - - ``ZSTR_EMPTY_ALLOC()`` | ||
| - Gets an immutable, empty string. This does not allocate memory. |
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. |
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. |
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 |
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 |
There was a problem hiding this comment.
Just to make things more accurate here
| - - ``ZSTR_ALLOCA_FREE(str, use_heap)`` | ||
| - Frees memory previously allocated with ``ZSTR_ALLOCA_ALLOC`` / ``ZSTR_ALLOCA_INIT``. | ||
|
|
||
| .. list-table:: Interned string APIs |
There was a problem hiding this comment.
This list, I know it's part of an API, but maybe it would be better to put it after the "Interned strings" section.
This PR added (and also fixed) some internal APIs concerning zend_string, cc @iluuu1994 as we privately talk about the doc work before.