Skip to content

Commit

Permalink
Fix PHP8 build (register_user_shutdown_function) (#3727)
Browse files Browse the repository at this point in the history
  • Loading branch information
twose authored Oct 9, 2020
1 parent 2fc271d commit 0de5350
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions php_swoole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ static void php_swoole_init_globals(zend_swoole_globals *swoole_globals) {

void php_swoole_register_shutdown_function(const char *function) {
php_shutdown_function_entry shutdown_function_entry;
zval *function_name;
#if PHP_VERSION_ID >= 80000
shutdown_function_entry.arg_count = 0;
shutdown_function_entry.arguments = NULL;
function_name = &shutdown_function_entry.function_name;
#else
shutdown_function_entry.arg_count = 1;
shutdown_function_entry.arguments = (zval *) safe_emalloc(sizeof(zval), 1, 0);
ZVAL_STRING(&shutdown_function_entry.arguments[0], function);
function_name = &shutdown_function_entry.arguments[0];
#endif
ZVAL_STRING(function_name, function);
register_user_shutdown_function(
(char *) function, ZSTR_LEN(Z_STR(shutdown_function_entry.arguments[0])), &shutdown_function_entry);
Z_STRVAL_P(function_name), Z_STRLEN_P(function_name), &shutdown_function_entry);
}

void php_swoole_set_global_option(HashTable *vht) {
Expand Down

0 comments on commit 0de5350

Please sign in to comment.