@@ -42,27 +42,10 @@ typedef struct {
4242 HashTable * name_to_dispid ; /* keep track of name -> dispid mappings */
4343
4444 GUID sinkid ; /* iid that we "implement" for event sinking */
45-
46- zend_resource * res ;
4745} php_dispatchex ;
4846
49- static int le_dispatch ;
50-
5147static void disp_destructor (php_dispatchex * disp );
5248
53- static void dispatch_dtor (zend_resource * rsrc )
54- {
55- php_dispatchex * disp = (php_dispatchex * )rsrc -> ptr ;
56- disp_destructor (disp );
57- }
58-
59- int php_com_wrapper_minit (INIT_FUNC_ARGS )
60- {
61- le_dispatch = zend_register_list_destructors_ex (dispatch_dtor ,
62- NULL , "com_dotnet_dispatch_wrapper" , module_number );
63- return le_dispatch ;
64- }
65-
6649
6750/* {{{ trace */
6851static inline void trace (char * fmt , ...)
@@ -129,8 +112,7 @@ static ULONG STDMETHODCALLTYPE disp_release(IDispatchEx *This)
129112 trace ("-- refcount now %d\n" , ret );
130113 if (ret == 0 ) {
131114 /* destroy it */
132- if (disp -> res )
133- zend_list_delete (disp -> res );
115+ disp_destructor (disp );
134116 }
135117 return ret ;
136118}
@@ -525,7 +507,6 @@ static void generate_dispids(php_dispatchex *disp)
525507static php_dispatchex * disp_constructor (zval * object )
526508{
527509 php_dispatchex * disp = (php_dispatchex * )CoTaskMemAlloc (sizeof (php_dispatchex ));
528- zval * tmp ;
529510
530511 trace ("constructing a COM wrapper for PHP object %p (%s)\n" , object , Z_OBJCE_P (object )-> name );
531512
@@ -545,26 +526,11 @@ static php_dispatchex *disp_constructor(zval *object)
545526 ZVAL_UNDEF (& disp -> object );
546527 }
547528
548- tmp = zend_list_insert (disp , le_dispatch );
549- disp -> res = Z_RES_P (tmp );
550-
551529 return disp ;
552530}
553531
554532static void disp_destructor (php_dispatchex * disp )
555533{
556- /* Object store not available during request shutdown */
557- if (COMG (rshutdown_started )) {
558- trace ("destroying COM wrapper for PHP object %p (name:unknown)\n" , Z_OBJ (disp -> object ));
559- } else {
560- trace ("destroying COM wrapper for PHP object %p (name:%s)\n" , Z_OBJ (disp -> object ), Z_OBJCE (disp -> object )-> name -> val );
561- }
562-
563- disp -> res = NULL ;
564-
565- if (disp -> refcount > 0 )
566- CoDisconnectObject ((IUnknown * )disp , 0 );
567-
568534 zend_hash_destroy (disp -> dispid_to_name );
569535 zend_hash_destroy (disp -> name_to_dispid );
570536 FREE_HASHTABLE (disp -> dispid_to_name );
0 commit comments