@@ -1511,8 +1511,7 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
15111511 bson_iter_t iter ;
15121512
15131513#if PHP_VERSION_ID >= 70000
1514- zval * client_ptr ;
1515- zval new_client_ptr ;
1514+ mongoc_client_t * client_ptr ;
15161515#else
15171516 mongoc_client_t * * client_ptr ;
15181517#endif
@@ -1523,9 +1522,9 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
15231522 }
15241523
15251524#if PHP_VERSION_ID >= 70000
1526- if ((client_ptr = zend_hash_str_find (& MONGODB_G (clients ), hash , hash_len )) && Z_TYPE_P ( client_ptr ) == IS_PTR ) {
1525+ if ((client_ptr = zend_hash_str_find_ptr (& MONGODB_G (clients ), hash , hash_len )) != NULL ) {
15271526 MONGOC_DEBUG ("Found client for hash: %s\n" , hash );
1528- manager -> client = ( mongoc_client_t * ) Z_PTR_P ( client_ptr ) ;
1527+ manager -> client = client_ptr ;
15291528 goto cleanup ;
15301529 }
15311530#else
@@ -1582,8 +1581,7 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
15821581
15831582 MONGOC_DEBUG ("Created client hash: %s\n" , hash );
15841583#if PHP_VERSION_ID >= 70000
1585- ZVAL_PTR (& new_client_ptr , manager -> client );
1586- zend_hash_str_update (& MONGODB_G (clients ), hash , hash_len , & new_client_ptr );
1584+ zend_hash_str_update_ptr (& MONGODB_G (clients ), hash , hash_len , manager -> client );
15871585#else
15881586 zend_hash_update (& MONGODB_G (clients ), hash , hash_len + 1 , & manager -> client , sizeof (mongoc_client_t * ), NULL );
15891587#endif
@@ -1984,6 +1982,18 @@ PHP_INI_BEGIN()
19841982PHP_INI_END ()
19851983/* }}} */
19861984
1985+ #if PHP_VERSION_ID >= 70000
1986+ static void php_phongo_client_dtor (zval * zv )
1987+ {
1988+ mongoc_client_destroy ((mongoc_client_t * ) Z_PTR_P (zv ));
1989+ }
1990+ #else
1991+ static void php_phongo_client_dtor (void * client )
1992+ {
1993+ mongoc_client_destroy (* ((mongoc_client_t * * ) client ));
1994+ }
1995+ #endif
1996+
19871997/* {{{ PHP_GINIT_FUNCTION */
19881998PHP_GINIT_FUNCTION (mongodb )
19891999{
@@ -1998,24 +2008,13 @@ PHP_GINIT_FUNCTION(mongodb)
19982008 ZEND_TSRMLS_CACHE_UPDATE ();
19992009#endif
20002010#endif
2001- mongodb_globals -> debug_fd = NULL ;
2011+ memset ( mongodb_globals , 0 , sizeof ( zend_mongodb_globals )) ;
20022012 mongodb_globals -> bsonMemVTable = bsonMemVTable ;
2003-
2013+ /* Initialize HashTable for persistent clients */
2014+ zend_hash_init_ex (& mongodb_globals -> clients , 0 , NULL , php_phongo_client_dtor , 1 , 0 );
20042015}
20052016/* }}} */
20062017
2007- #if PHP_VERSION_ID >= 70000
2008- static void php_phongo_client_dtor (zval * zv )
2009- {
2010- mongoc_client_destroy ((mongoc_client_t * ) Z_PTR_P (zv ));
2011- }
2012- #else
2013- static void php_phongo_client_dtor (void * client )
2014- {
2015- mongoc_client_destroy (* ((mongoc_client_t * * ) client ));
2016- }
2017- #endif
2018-
20192018/* {{{ PHP_MINIT_FUNCTION */
20202019PHP_MINIT_FUNCTION (mongodb )
20212020{
@@ -2037,9 +2036,6 @@ PHP_MINIT_FUNCTION(mongodb)
20372036 /* Initialize libbson */
20382037 bson_mem_set_vtable (& MONGODB_G (bsonMemVTable ));
20392038
2040- /* Initialize HashTable for persistent clients */
2041- zend_hash_init (& MONGODB_G (clients ), 0 , NULL , php_phongo_client_dtor , 1 );
2042-
20432039 /* Prep default object handlers to be used when we register the classes */
20442040 memcpy (& phongo_std_object_handlers , zend_get_std_object_handlers (), sizeof (zend_object_handlers ));
20452041 phongo_std_object_handlers .clone_obj = NULL ;
0 commit comments