Skip to content

Commit b678e5f

Browse files
committed
Re-add resource variant
1 parent 66a27cf commit b678e5f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Zend/zend_API.h

+8
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,14 @@ static zend_always_inline void add_property_stringl(zval *z_object, const char *
555555
static zend_always_inline void add_property_stringl_ex(zval *z_object, const char *name, size_t name_length, const char *value, size_t value_len) {
556556
zend_update_property_stringl(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value, value_len);
557557
}
558+
/* Resource variant only has non ex version as it is rarely used */
559+
static zend_always_inline void add_property_resource(zval *z_object, const char *name, zend_resource *resource) {
560+
zval tmp;
561+
562+
ZVAL_REF(&tmp, resource);
563+
zend_update_property(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), &tmp);
564+
zval_ptr_dtor(&tmp); /* Updating property will increase refcount by 1 */
565+
}
558566

559567
ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value);
560568
ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);

0 commit comments

Comments
 (0)