mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Switch reflection to use smart_str
Instead of yet-another-smart-string-implementation. Expand the smart_str API by: * smart_str_extract() which gets a finalized zend_string* from a smart_str, including insertion of the zero byte and handling of the empty string case. This should be preferred over using smart_str_0() in conjunction with str.s. * smart_str_get_len() which gets the length of the smart_str with handling of the empty string case.
This commit is contained in:
parent
384e959a3a
commit
f3f594a47d
@ -20,6 +20,7 @@
|
||||
#define ZEND_SMART_STR_H
|
||||
|
||||
#include <zend.h>
|
||||
#include "zend_globals.h"
|
||||
#include "zend_smart_str_public.h"
|
||||
|
||||
#define smart_str_appends_ex(dest, src, what) \
|
||||
@ -82,6 +83,22 @@ static zend_always_inline void smart_str_0(smart_str *str) {
|
||||
}
|
||||
}
|
||||
|
||||
static zend_always_inline size_t smart_str_get_len(smart_str *str) {
|
||||
return str->s ? ZSTR_LEN(str->s) : 0;
|
||||
}
|
||||
|
||||
static zend_always_inline zend_string *smart_str_extract(smart_str *str) {
|
||||
if (str->s) {
|
||||
zend_string *res;
|
||||
smart_str_0(str);
|
||||
res = str->s;
|
||||
str->s = NULL;
|
||||
return res;
|
||||
} else {
|
||||
return ZSTR_EMPTY_ALLOC();
|
||||
}
|
||||
}
|
||||
|
||||
static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) {
|
||||
size_t new_len = smart_str_alloc(dest, 1, persistent);
|
||||
ZSTR_VAL(dest->s)[new_len - 1] = ch;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user