@@ -101,7 +101,8 @@ hashing, and interning helpers.
101101 - - ``ZSTR_KNOWN(ZEND_STR_const) ``
102102
103103 - Gets an immutable, predefined string. Used for string common within PHP itself, e.g.
104- ``"class" ``. See ``ZEND_KNOWN_STRINGS `` in ``Zend/zend_string.h ``. This does not allocate memory.
104+ ``"class" ``. See ``ZEND_KNOWN_STRINGS `` in ``Zend/zend_string.h ``. This does not allocate
105+ memory.
105106
106107 - - ``ZSTR_MAX_OVERHEAD ``
107108 - Maximum allocator/header overhead used by ``zend_string ``.
@@ -116,13 +117,14 @@ hashing, and interning helpers.
116117 - Description
117118
118119 - - ``zend_string_realloc(s, l, p) ``
120+
119121 - Changes the size of the string. If the string has a reference count greater than 1 or if
120122 the string is interned, a new string is created. You must always use the return value of
121123 this function, as the original array may have been moved to a new location in memory.
122124
123125 - - ``zend_string_safe_realloc(s, n, m, l, p) ``
124- - Resizes a string to ``n * m + l `` bytes with overflow checks. Allocates a string of
125- length ``n * m + l ``. This function is commonly useful for encoding changes.
126+ - Resizes a string to ``n * m + l `` bytes with overflow checks. Allocates a string of length
127+ ``n * m + l ``. This function is commonly useful for encoding changes.
126128
127129 - - ``zend_string_extend(s, l, p) ``
128130 - Extends a string to a larger length (``l >= ZSTR_LEN(s) ``).
@@ -140,8 +142,8 @@ hashing, and interning helpers.
140142
141143.. [#persistent ]
142144
143- ``s `` = ``zend_string ``, ``l `` = ``length ``, ``p `` = ``persistent ``,
144- `` n * m + l `` = checked size expression used for safe allocation/reallocation.
145+ ``s `` = ``zend_string ``, ``l `` = ``length ``, ``p `` = ``persistent ``, `` n * m + l `` = checked size
146+ expression used for safe allocation/reallocation.
145147
146148 As per php-src fashion, you are not supposed to access the ``zend_string `` fields directly. Instead,
147149use the following macros. There are macros for both ``zend_string `` and ``zvals `` known to contain
@@ -175,10 +177,8 @@ strings.
175177
176178 - - Macro
177179 - Description
178-
179180 - - ``ZSTR_IS_INTERNED(s) ``
180181 - Checks whether a string is interned.
181-
182182 - - ``ZSTR_IS_VALID_UTF8(s) ``
183183 - Checks whether a string has the ``IS_STR_VALID_UTF8 `` flag set.
184184
@@ -196,9 +196,10 @@ strings.
196196 - Returns the reference count. Interned strings always report ``1 ``.
197197
198198 - - ``zend_string_addref(s) ``
199- - Increments the reference count of a non-interned string. the function that is used
200- most often by far is zend_string_copy(). This function not only increments the refcount,
201- but also returns the original string. This makes code more readable in practice.
199+
200+ - Increments the reference count of a non-interned string. the function that is used most
201+ often by far is zend_string_copy(). This function not only increments the refcount, but
202+ also returns the original string. This makes code more readable in practice.
202203
203204 - - ``zend_string_delref(s) ``
204205 - Decrements the reference count of a non-interned string.
@@ -211,14 +212,15 @@ strings.
211212 persistent or non-persistent. If it is persistent, ``p `` should be ``0 ``.
212213
213214 - - ``zend_string_free(s) ``
215+
214216 - Frees a non-interned string directly. The caller must ensure it is no longer shared.
215- Requires refcount 1 or immutable.You should avoid using these functions, as it is
216- easy to introduce critical bugs when some API changes from returning new strings to
217- reusing existing ones.
217+ Requires refcount 1 or immutable.You should avoid using these functions, as it is easy to
218+ introduce critical bugs when some API changes from returning new strings to reusing
219+ existing ones.
218220
219221 - - ``zend_string_efree(s) ``
220- - Similar to ``zend_string_free ``. Frees a non-persistent, non-interned string
221- with ``efree ``. Requires refcount 1 and not immutable.
222+ - Similar to ``zend_string_free ``. Frees a non-persistent, non-interned string with
223+ ``efree ``. Requires refcount 1 and not immutable.
222224
223225There are various functions to compare strings.
224226
@@ -227,43 +229,30 @@ There are various functions to compare strings.
227229
228230 - - Function/Macro
229231 - Description
230-
231232 - - ``zend_string_equals(s1, s2) ``
232233 - Full equality check for two ``zend_string `` values.
233-
234234 - - ``zend_string_equal_content(s1, s2) ``
235235 - Full equality check assuming both arguments are ``zend_string `` pointers.
236-
237236 - - ``zend_string_equal_val(s1, s2) ``
238237 - Compares only the string payload bytes (caller must ensure equal lengths).
239-
240238 - - ``zend_string_equals_cstr(s1, s2, l2) ``
241239 - Compares a ``zend_string `` with a ``char* `` buffer and explicit length.
242-
243240 - - ``zend_string_equals_ci(s1, s2) ``
244241 - Case-insensitive full equality check.
245-
246242 - - ``zend_string_equals_literal(str, literal) ``
247243 - Equality check against a string literal with compile-time literal length.
248-
249244 - - ``zend_string_equals_literal_ci(str, literal) ``
250245 - Case-insensitive literal equality check.
251-
252246 - - ``zend_string_starts_with(str, prefix) ``
253247 - Checks whether ``str `` begins with ``prefix ``.
254-
255248 - - ``zend_string_starts_with_cstr(str, prefix, prefix_length) ``
256249 - Prefix check against a ``char* `` buffer and explicit length.
257-
258250 - - ``zend_string_starts_with_ci(str, prefix) ``
259251 - Case-insensitive prefix check for two ``zend_string `` values.
260-
261252 - - ``zend_string_starts_with_cstr_ci(str, prefix, prefix_length) ``
262253 - Case-insensitive prefix check against a ``char* `` buffer.
263-
264254 - - ``zend_string_starts_with_literal(str, prefix) ``
265255 - Prefix check against a string literal.
266-
267256 - - ``zend_string_starts_with_literal_ci(str, prefix) ``
268257 - Case-insensitive prefix check against a string literal.
269258
@@ -272,19 +261,14 @@ There are various functions to compare strings.
272261
273262 - - Function/Macro
274263 - Description
275-
276264 - - ``zend_string_hash_func(s) ``
277265 - Computes and stores the hash for ``s ``.
278-
279266 - - ``zend_string_hash_val(s) ``
280267 - Returns the cached hash if available, otherwise computes it.
281-
282268 - - ``zend_hash_func(str, len) ``
283269 - Computes a hash for a raw ``char* `` buffer.
284-
285270 - - ``zend_inline_hash_func(str, len) ``
286271 - Inline implementation of PHP's string hashing routine for ``char* `` buffers.
287-
288272 - - ``zend_string_forget_hash_val(s) ``
289273 - Clears cached hash/derived flags after string contents change.
290274
@@ -293,19 +277,14 @@ There are various functions to compare strings.
293277
294278 - - Macro
295279 - Description
296-
297280 - - ``ZSTR_COPYABLE_CONCAT_PROPERTIES ``
298281 - Bitmask of string flags that can be preserved when concatenating strings.
299-
300282 - - ``ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(s) ``
301283 - Extracts copyable concatenation properties from one string.
302-
303284 - - ``ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(s1, s2) ``
304285 - Extracts copyable properties shared by both input strings.
305-
306286 - - ``ZSTR_COPY_CONCAT_PROPERTIES(out, in) ``
307287 - Copies concatenation properties from one input to the output string.
308-
309288 - - ``ZSTR_COPY_CONCAT_PROPERTIES_BOTH(out, in1, in2) ``
310289 - Copies only properties that are set on both inputs.
311290
@@ -314,13 +293,10 @@ There are various functions to compare strings.
314293
315294 - - Macro
316295 - Description
317-
318296 - - ``ZSTR_ALLOCA_ALLOC(str, l, use_heap) ``
319297 - Allocates a temporary string buffer using ``do_alloca ``.
320-
321298 - - ``ZSTR_ALLOCA_INIT(str, s, l, use_heap) ``
322299 - Same as ``ZSTR_ALLOCA_ALLOC ``, then copies data from ``s `` and appends ``'\0' ``.
323-
324300 - - ``ZSTR_ALLOCA_FREE(str, use_heap) ``
325301 - Frees memory previously allocated with ``ZSTR_ALLOCA_ALLOC `` / ``ZSTR_ALLOCA_INIT ``.
326302
@@ -329,34 +305,24 @@ There are various functions to compare strings.
329305
330306 - - Function
331307 - Description
332-
333308 - - ``zend_new_interned_string(s) ``
334309 - Interns ``s `` if possible and returns the interned instance.
335-
336310 - - ``zend_string_init_interned(str, len, p) ``
337311 - Creates or fetches an interned string from raw bytes.
338-
339312 - - ``zend_string_init_existing_interned(str, len, p) ``
340313 - Returns an interned string only if it already exists; does not create a new one.
341-
342314 - - ``zend_interned_string_find_permanent(s) ``
343315 - Looks up ``s `` in the permanent interned string storage.
344-
345316 - - ``zend_interned_strings_init() ``
346317 - Initializes interned string storage during engine startup.
347-
348318 - - ``zend_interned_strings_dtor() ``
349319 - Destroys interned string storage during engine shutdown.
350-
351320 - - ``zend_interned_strings_activate() ``
352321 - Activates request-local interned string state.
353-
354322 - - ``zend_interned_strings_deactivate() ``
355323 - Deactivates request-local interned string state.
356-
357324 - - ``zend_interned_strings_set_request_storage_handlers(...) ``
358325 - Installs callbacks that customize request interned string storage behavior.
359-
360326 - - ``zend_interned_strings_switch_storage(request) ``
361327 - Switches between request and persistent interned string storage backends.
362328
0 commit comments