diff options
Diffstat (limited to 'Zend/zend_smart_str.h')
-rw-r--r-- | Zend/zend_smart_str.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h index f31d53e019..0d61b56a67 100644 --- a/Zend/zend_smart_str.h +++ b/Zend/zend_smart_str.h @@ -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) \ @@ -46,6 +47,8 @@ BEGIN_EXTERN_C() ZEND_API void ZEND_FASTCALL smart_str_erealloc(smart_str *str, size_t len); ZEND_API void ZEND_FASTCALL smart_str_realloc(smart_str *str, size_t len); ZEND_API void ZEND_FASTCALL smart_str_append_escaped(smart_str *str, const char *s, size_t l); +ZEND_API void ZEND_FASTCALL smart_str_append_printf(smart_str *dest, const char *format, ...) + ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); END_EXTERN_C() @@ -80,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; |