Hi,
I'd like your comments on a PR (https://github.com/php/php-src/pull/1353) I
just wrote to propose two changes to the zend_string API. Both are different
but, as they apply to the same file, it was easier to merge them the same PR
:
- Suppress the 'persistent' arg from zend_string realloc/extend/truncate
functions
This argument is useless because :
- perealloc() cannot re-allocate from non-persistent memory to
persistent or from persistent to non-persistent. So, the 'persistent'
argument value we give to the zend_string_realloc() function is totally
constrained : it must be the same as the value provided when the
zend_string was created.
- This information is present in the zend_string structure as
(GC_FLAGS(s) & IS_STR_PERSISTENT).
So, the 'persistent' argument is useless and can only lead to failures.
That's why I propose we remove it from the API as soon as possible (7.0.0
alpha2 ?). It creates a small BC break for extension maintainers, but I
think it's still better than pulling this behind us during years. As an
indication of the BC break for extension maintainers, the whole core
distribution contains about 50 calls to one of these functions (PR includes
fixes).
- Add a set of zend_string_append() functions
Added functions to append to a zend_string from :
- another zend_string,
- a pair (char *, len),
- a literal string,
- or a null-terminated string (using `strlen()`).
IMHO, these features are common enough to be part of the API.
Regards
François