@@ -1511,8 +1511,7 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1511
1511
bson_iter_t iter ;
1512
1512
1513
1513
#if PHP_VERSION_ID >= 70000
1514
- zval * client_ptr ;
1515
- zval new_client_ptr ;
1514
+ mongoc_client_t * client_ptr ;
1516
1515
#else
1517
1516
mongoc_client_t * * client_ptr ;
1518
1517
#endif
@@ -1523,9 +1522,9 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1523
1522
}
1524
1523
1525
1524
#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 ) {
1527
1526
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 ;
1529
1528
goto cleanup ;
1530
1529
}
1531
1530
#else
@@ -1582,8 +1581,7 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1582
1581
1583
1582
MONGOC_DEBUG ("Created client hash: %s\n" , hash );
1584
1583
#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 );
1587
1585
#else
1588
1586
zend_hash_update (& MONGODB_G (clients ), hash , hash_len + 1 , & manager -> client , sizeof (mongoc_client_t * ), NULL );
1589
1587
#endif
@@ -1984,6 +1982,18 @@ PHP_INI_BEGIN()
1984
1982
PHP_INI_END ()
1985
1983
/* }}} */
1986
1984
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
+
1987
1997
/* {{{ PHP_GINIT_FUNCTION */
1988
1998
PHP_GINIT_FUNCTION (mongodb )
1989
1999
{
@@ -1998,24 +2008,13 @@ PHP_GINIT_FUNCTION(mongodb)
1998
2008
ZEND_TSRMLS_CACHE_UPDATE ();
1999
2009
#endif
2000
2010
#endif
2001
- mongodb_globals -> debug_fd = NULL ;
2011
+ memset ( mongodb_globals , 0 , sizeof ( zend_mongodb_globals )) ;
2002
2012
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 );
2004
2015
}
2005
2016
/* }}} */
2006
2017
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
-
2019
2018
/* {{{ PHP_MINIT_FUNCTION */
2020
2019
PHP_MINIT_FUNCTION (mongodb )
2021
2020
{
@@ -2037,9 +2036,6 @@ PHP_MINIT_FUNCTION(mongodb)
2037
2036
/* Initialize libbson */
2038
2037
bson_mem_set_vtable (& MONGODB_G (bsonMemVTable ));
2039
2038
2040
- /* Initialize HashTable for persistent clients */
2041
- zend_hash_init (& MONGODB_G (clients ), 0 , NULL , php_phongo_client_dtor , 1 );
2042
-
2043
2039
/* Prep default object handlers to be used when we register the classes */
2044
2040
memcpy (& phongo_std_object_handlers , zend_get_std_object_handlers (), sizeof (zend_object_handlers ));
2045
2041
phongo_std_object_handlers .clone_obj = NULL ;
0 commit comments