Skip to content

zend_smart_string: Add smart_string_append_printf() #18160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PHP 8.5 INTERNALS UPGRADE NOTES
could interfere.
. zend_get_callable_name() now returns the name of the underlying function
for fake closures.
. Added smart_string_append_printf() matching smart_str_append_printf() for
char* instead of zend_string*-based smart strings.

========================
2. Build system changes
Expand Down
7 changes: 7 additions & 0 deletions Zend/zend_smart_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ ZEND_API void smart_str_append_printf(smart_str *dest, const char *format, ...)
va_end(arg);
}

ZEND_API void smart_string_append_printf(smart_string *dest, const char *format, ...) {
va_list arg;
va_start(arg, format);
zend_printf_to_smart_string(dest, format, arg);
va_end(arg);
}

#define SMART_STRING_OVERHEAD (ZEND_MM_OVERHEAD + 1)
#define SMART_STRING_START_SIZE 256
#define SMART_STRING_START_LEN (SMART_STRING_START_SIZE - SMART_STRING_OVERHEAD)
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_smart_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#define smart_string_append_unsigned(str, val) \
smart_string_append_unsigned_ex((str), (val), 0)

ZEND_API void smart_string_append_printf(smart_string *dest, const char *format, ...)
ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);

ZEND_API void ZEND_FASTCALL _smart_string_alloc_persistent(smart_string *str, size_t len);
ZEND_API void ZEND_FASTCALL _smart_string_alloc(smart_string *str, size_t len);

Expand Down