Skip to content

Commit

Permalink
Merge branch 'main' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 13, 2023
2 parents 9f0fb15 + dec3ad0 commit 9bd71f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
23 changes: 13 additions & 10 deletions preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,20 @@ function ffi_char_variadic(string ...$string): CData
*/
function ffi_char_assoc(array ...$items): CData
{
$i = 0;
$environment = \FFI::new('char*[' . (\count($items) + 1) . ']', false);
foreach ($items as $key => $value) {
$is = \is_array($value);
$key = $is ? \array_key_first($value) : $key;
$entry = \sprintf('%s=%s', $key, $is ? $value[$key] : $value);
$environment[$i] = \ffi_char($entry);
$i++;
try {
$i = 0;
$environment = \FFI::new('char*[' . (\count($items) + 1) . ']', false);
foreach ($items as $key => $value) {
$is = \is_array($value);
$key = $is ? \array_key_first($value) : $key;
$entry = \sprintf('%s=%s', $key, $is ? @\array_values($value)[0] : $value);
$environment[$i] = \ffi_char($entry);
$i++;
}
$environment[$i] = NULL;
} catch (\Throwable $e) {
$environment = \ffi_null();
}
$environment[$i] = NULL;

return \ze_cast('char**', $environment);
}
Expand Down Expand Up @@ -821,7 +825,6 @@ function zend_preloader(): void
}

\setup_ffi_loader('ts', $header);
\tsrmls_cache_define();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions zend/StandardModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ final public function __construct(
$this->startup();
}

if (\PHP_ZTS)
\tsrmls_cache_define();

if (\PHP_ZTS && \is_null($this->module_mutex))
$this->module_mutex = \ze_ffi()->tsrm_mutex_alloc();
}
Expand Down

0 comments on commit 9bd71f2

Please sign in to comment.