[php-src] master: Zend: add zend_object_copy() API

From: Date: Thu, 01 Oct 2026 11:44:18 +0000
Subject: [php-src] master: Zend: add zend_object_copy() API
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141823@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-10-01T12:43:39+01:00 Commit: https://github.com/php/php-src/commit/c94d7911ab1946a9c096b0937d1646e8165cbb13 Raw diff: https://github.com/php/php-src/commit/c94d7911ab1946a9c096b0937d1646e8165cbb13.diff Zend: add zend_object_copy() API Closes GH-24036 Changed paths: M UPGRADING.INTERNALS M Zend/zend_objects_API.h Diff: diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index fa905cb1e535..08f23f690fbe 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -35,6 +35,9 @@ PHP 8.7 INTERNALS UPGRADE NOTES This new signature covers the most common parameters used with zend_is_callable_ex(). - Removed zend_hrtime_posix_clock_id. zend_hrtime() always uses CLOCK_MONOTONIC on POSIX platforms. +- Added a new zend_object_copy() function which increases the refcount of + a zend_object* and returns it. Allowing more descriptive code rather than + doing an assignment followed by GC_ADDREF(). ======================== 2. Build system changes diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index 434ac4499e7f..b66a3d307e55 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -70,6 +70,13 @@ static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj) END_EXTERN_C() +/** Increase the refcount and return the input */ +static zend_always_inline zend_object *zend_object_copy(zend_object *obj) +{ + GC_ADDREF(obj); + return obj; +} + static zend_always_inline void zend_object_release(zend_object *obj) { if (GC_DELREF(obj) == 0) {

« previous php.cvs (#141823) next »