Skip to content

Commit 5864baf

Browse files
committed
ext/bz2: Replace zend_parse_parameters() with ZEND_PARSE_PARAMETERS macros
1 parent 4188c3e commit 5864baf

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

ext/bz2/bz2.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,10 @@ PHP_FUNCTION(bzopen)
336336
BZFILE *bz; /* The compressed file stream */
337337
php_stream *stream = NULL;
338338

339-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &file, &mode, &mode_len) == FAILURE) {
340-
RETURN_THROWS();
341-
}
339+
ZEND_PARSE_PARAMETERS_START(2, 2)
340+
Z_PARAM_ZVAL(file)
341+
Z_PARAM_STRING(mode, mode_len)
342+
ZEND_PARSE_PARAMETERS_END();
342343

343344
if (mode_len != 1 || (mode[0] != 'r' && mode[0] != 'w')) {
344345
zend_argument_value_error(2, "must be either \"r\" or \"w\"");
@@ -456,9 +457,12 @@ PHP_FUNCTION(bzcompress)
456457
size_t source_len; /* Length of the source data */
457458
unsigned int dest_len; /* Length of the destination buffer */
458459

459-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|ll", &source, &source_len, &zblock_size, &zwork_factor) == FAILURE) {
460-
RETURN_THROWS();
461-
}
460+
ZEND_PARSE_PARAMETERS_START(1, 3)
461+
Z_PARAM_STRING(source, source_len)
462+
Z_PARAM_OPTIONAL
463+
Z_PARAM_LONG(zblock_size)
464+
Z_PARAM_LONG(zwork_factor)
465+
ZEND_PARSE_PARAMETERS_END();
462466

463467
if (zblock_size < 1 || zblock_size > 9) {
464468
zend_argument_value_error(2, "must be between 1 and 9");
@@ -514,9 +518,11 @@ PHP_FUNCTION(bzdecompress)
514518
uint64_t size = 0;
515519
bz_stream bzs;
516520

517-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &source, &source_len, &small)) {
518-
RETURN_THROWS();
519-
}
521+
ZEND_PARSE_PARAMETERS_START(1, 2)
522+
Z_PARAM_STRING(source, source_len)
523+
Z_PARAM_OPTIONAL
524+
Z_PARAM_BOOL(small)
525+
ZEND_PARSE_PARAMETERS_END();
520526

521527
bzs.bzalloc = NULL;
522528
bzs.bzfree = NULL;

0 commit comments

Comments
 (0)