Skip to content

Commit

Permalink
Replace zend_atol with zend_ini_prse_quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFreeman committed Sep 14, 2024
1 parent 78a9ac5 commit 0e2e0ee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ext-src/php_swoole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,21 @@ SW_API bool php_swoole_is_enable_coroutine() {

SW_API zend_long php_swoole_parse_to_size(zval *zv) {
if (ZVAL_IS_STRING(zv)) {
#if PHP_VERSION_ID >= 80200
zend_string *errstr;
auto size = zend_ini_parse_quantity(Z_STR_P(zv), &errstr);
if (errstr) {
php_swoole_fatal_error(
E_ERROR, "failed to parse '%s' to size, Error: %s", Z_STRVAL_P(zv), ZSTR_VAL(errstr));
zend_string_release(errstr);
}
return size;
#else
return zend_atol(Z_STRVAL_P(zv), Z_STRLEN_P(zv));
#endif
} else {
return zval_get_long(zv);
}
}

static void fatal_error(int code, const char *format, ...) {
va_list args;
Expand Down

0 comments on commit 0e2e0ee

Please sign in to comment.