@@ -2548,7 +2548,7 @@ static char* php_phongo_manager_make_client_hash(const char* uri_string, zval* o
2548
2548
2549
2549
if (!EG (exception )) {
2550
2550
* hash_len = ZSTR_LEN (var_buf .s );
2551
- hash = pestrndup (ZSTR_VAL (var_buf .s ), * hash_len , 1 );
2551
+ hash = estrndup (ZSTR_VAL (var_buf .s ), * hash_len );
2552
2552
}
2553
2553
2554
2554
zval_ptr_dtor (& args );
@@ -2580,7 +2580,7 @@ static char* php_phongo_manager_make_client_hash(const char* uri_string, zval* o
2580
2580
2581
2581
if (!EG (exception )) {
2582
2582
* hash_len = var_buf .len ;
2583
- hash = pestrndup (var_buf .c , * hash_len , 1 );
2583
+ hash = estrndup (var_buf .c , * hash_len );
2584
2584
}
2585
2585
2586
2586
zval_ptr_dtor (& args );
@@ -2655,21 +2655,19 @@ static mongoc_client_t* php_phongo_find_client(const char* hash, size_t hash_len
2655
2655
2656
2656
void phongo_manager_init (php_phongo_manager_t * manager , const char * uri_string , zval * options , zval * driverOptions TSRMLS_DC ) /* {{{ */
2657
2657
{
2658
- char * hash = NULL ;
2659
- size_t hash_len = 0 ;
2660
2658
bson_t bson_options = BSON_INITIALIZER ;
2661
2659
mongoc_uri_t * uri = NULL ;
2662
2660
#ifdef MONGOC_ENABLE_SSL
2663
2661
mongoc_ssl_opt_t * ssl_opt = NULL ;
2664
2662
#endif
2665
2663
2666
- if (!(hash = php_phongo_manager_make_client_hash (uri_string , options , driverOptions , & hash_len TSRMLS_CC ))) {
2664
+ if (!(manager -> client_hash = php_phongo_manager_make_client_hash (uri_string , options , driverOptions , & manager -> client_hash_len TSRMLS_CC ))) {
2667
2665
/* Exception should already have been thrown and there is nothing to free */
2668
2666
return ;
2669
2667
}
2670
2668
2671
- if ((manager -> client = php_phongo_find_client (hash , hash_len TSRMLS_CC ))) {
2672
- MONGOC_DEBUG ("Found client for hash: %s\n" , hash );
2669
+ if ((manager -> client = php_phongo_find_client (manager -> client_hash , manager -> client_hash_len TSRMLS_CC ))) {
2670
+ MONGOC_DEBUG ("Found client for hash: %s\n" , manager -> client_hash );
2673
2671
goto cleanup ;
2674
2672
}
2675
2673
@@ -2733,14 +2731,10 @@ void phongo_manager_init(php_phongo_manager_t* manager, const char* uri_string,
2733
2731
}
2734
2732
#endif
2735
2733
2736
- MONGOC_DEBUG ("Created client hash: %s\n" , hash );
2737
- php_phongo_persist_client (hash , hash_len , manager -> client TSRMLS_CC );
2734
+ MONGOC_DEBUG ("Created client hash: %s\n" , manager -> client_hash );
2735
+ php_phongo_persist_client (manager -> client_hash , manager -> client_hash_len , manager -> client TSRMLS_CC );
2738
2736
2739
2737
cleanup :
2740
- if (hash ) {
2741
- pefree (hash , 1 );
2742
- }
2743
-
2744
2738
bson_destroy (& bson_options );
2745
2739
2746
2740
if (uri ) {
0 commit comments