Skip to content
Prev Previous commit
Next Next commit
ext/standard: Use new php_streams fast ZPP specifier
  • Loading branch information
Girgias committed Mar 3, 2025
commit f4f01626c653b56e34fad70aef7b762842f6dc63
14 changes: 5 additions & 9 deletions ext/standard/formatted_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,18 +860,16 @@ PHP_FUNCTION(fprintf)
php_stream *stream;
char *format;
size_t format_len;
zval *arg1, *args;
int argc;
zval *args = NULL;
int argc = 0;
zend_string *result;

ZEND_PARSE_PARAMETERS_START(2, -1)
Z_PARAM_RESOURCE(arg1)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_STRING(format, format_len)
Z_PARAM_VARIADIC('*', args, argc)
ZEND_PARSE_PARAMETERS_END();

php_stream_from_zval(stream, arg1);

result = php_formatted_print(format, format_len, args, argc, 2);
if (result == NULL) {
RETURN_THROWS();
Expand All @@ -890,19 +888,17 @@ PHP_FUNCTION(vfprintf)
php_stream *stream;
char *format;
size_t format_len;
zval *arg1, *args;
zval *args;
zend_array *array;
int argc;
zend_string *result;

ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_RESOURCE(arg1)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_STRING(format, format_len)
Z_PARAM_ARRAY_HT(array)
ZEND_PARSE_PARAMETERS_END();

php_stream_from_zval(stream, arg1);

args = php_formatted_print_get_array(array, &argc);

result = php_formatted_print(format, format_len, args, argc, -1);
Expand Down
5 changes: 2 additions & 3 deletions ext/standard/user_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,18 @@ PHP_FUNCTION(stream_bucket_append)
/* {{{ Create a new bucket for use on the current stream */
PHP_FUNCTION(stream_bucket_new)
{
zval *zstream, zbucket;
zval zbucket;
php_stream *stream;
char *buffer;
char *pbuffer;
size_t buffer_len;
php_stream_bucket *bucket;

ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL(zstream)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_STRING(buffer, buffer_len)
ZEND_PARSE_PARAMETERS_END();

php_stream_from_zval(stream, zstream);
pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream));

memcpy(pbuffer, buffer, buffer_len);
Expand Down