From e0836e5f20419a2d57fb458efc9a6d72d7a5b4f5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 27 Jan 2025 18:30:13 +0100 Subject: [PATCH 1/2] Drop superfluous php_com_dotnet_object.ce This is readily available via the `zend_object` (i.e. `zo.ce`), so there is no need to duplicate it. --- ext/com_dotnet/com_handlers.c | 5 ++--- ext/com_dotnet/com_misc.c | 2 -- ext/com_dotnet/php_com_dotnet_internal.h | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index fcbae4e34621f..5a177457a4492 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -307,7 +307,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name f.type = ZEND_INTERNAL_FUNCTION; f.num_args = 0; f.arg_info = NULL; - f.scope = obj->ce; + f.scope = obj->zo.ce; f.fn_flags = ZEND_ACC_CALL_VIA_HANDLER; f.function_name = zend_string_copy(name); f.handler = PHP_FN(com_method_handler); @@ -392,7 +392,7 @@ static zend_string* com_class_name_get(const zend_object *object) { php_com_dotnet_object *obj = (php_com_dotnet_object *)object; - return zend_string_copy(obj->ce->name); + return zend_string_copy(obj->zo.ce->name); } /* This compares two variants for equality */ @@ -625,7 +625,6 @@ zend_object* php_com_object_new(zend_class_entry *ce) VariantInit(&obj->v); obj->code_page = CP_ACP; - obj->ce = ce; zend_object_std_init(&obj->zo, ce); diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 3c85fc4ce5e4a..326c0587bff42 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -50,7 +50,6 @@ PHP_COM_DOTNET_API void php_com_wrap_dispatch(zval *z, IDispatch *disp, obj = emalloc(sizeof(*obj)); memset(obj, 0, sizeof(*obj)); obj->code_page = codepage; - obj->ce = php_com_variant_class_entry; obj->zo.ce = php_com_variant_class_entry; VariantInit(&obj->v); @@ -72,7 +71,6 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, obj = emalloc(sizeof(*obj)); memset(obj, 0, sizeof(*obj)); obj->code_page = codepage; - obj->ce = php_com_variant_class_entry; obj->zo.ce = php_com_variant_class_entry; VariantInit(&obj->v); diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index 90c3ab2d40e41..09fe494393470 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -35,8 +35,6 @@ typedef struct _php_com_dotnet_object { ITypeInfo *typeinfo; - zend_class_entry *ce; - /* associated event sink */ IDispatch *sink_dispatch; GUID sink_id; From adebef9ae8fd3fcd3918e9c6de794ce1d1dc8e81 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 27 Jan 2025 19:45:28 +0100 Subject: [PATCH 2/2] Drop further superfluous assignments --- ext/com_dotnet/com_misc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 326c0587bff42..a5de6415b9a73 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -50,7 +50,6 @@ PHP_COM_DOTNET_API void php_com_wrap_dispatch(zval *z, IDispatch *disp, obj = emalloc(sizeof(*obj)); memset(obj, 0, sizeof(*obj)); obj->code_page = codepage; - obj->zo.ce = php_com_variant_class_entry; VariantInit(&obj->v); V_VT(&obj->v) = VT_DISPATCH; @@ -71,7 +70,6 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, obj = emalloc(sizeof(*obj)); memset(obj, 0, sizeof(*obj)); obj->code_page = codepage; - obj->zo.ce = php_com_variant_class_entry; VariantInit(&obj->v); VariantCopyInd(&obj->v, v);