@@ -163,22 +163,17 @@ static zend_function *pgsql_link_get_constructor(zend_object *object) {
163
163
static void pgsql_link_free (pgsql_link_handle * link )
164
164
{
165
165
PGresult * res ;
166
- zval * hash ;
167
166
168
167
while ((res = PQgetResult (link -> conn ))) {
169
168
PQclear (res );
170
169
}
171
170
PQfinish (link -> conn );
172
171
PGG (num_links )-- ;
173
172
174
- /* Remove connection hash for this link */
175
- hash = zend_hash_index_find (& PGG (hashes ), (uintptr_t ) link -> conn );
176
- if (hash ) {
177
- zend_hash_index_del (& PGG (hashes ), (uintptr_t ) link -> conn );
178
- zend_hash_del (& PGG (regular_list ), Z_STR_P (hash ));
179
- }
173
+ zend_hash_del (& PGG (regular_list ), link -> hash );
180
174
181
175
link -> conn = NULL ;
176
+ zend_string_release (link -> hash );
182
177
}
183
178
184
179
static void pgsql_link_free_obj (zend_object * obj )
@@ -415,7 +410,6 @@ static PHP_GINIT_FUNCTION(pgsql)
415
410
memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
416
411
/* Initialize notice message hash at MINIT only */
417
412
zend_hash_init (& pgsql_globals -> notices , 0 , NULL , ZVAL_PTR_DTOR , 1 );
418
- zend_hash_init (& pgsql_globals -> hashes , 0 , NULL , ZVAL_PTR_DTOR , 1 );
419
413
zend_hash_init (& pgsql_globals -> regular_list , 0 , NULL , ZVAL_PTR_DTOR , 1 );
420
414
}
421
415
@@ -588,7 +582,6 @@ PHP_MSHUTDOWN_FUNCTION(pgsql)
588
582
{
589
583
UNREGISTER_INI_ENTRIES ();
590
584
zend_hash_destroy (& PGG (notices ));
591
- zend_hash_destroy (& PGG (hashes ));
592
585
zend_hash_destroy (& PGG (regular_list ));
593
586
594
587
return SUCCESS ;
@@ -605,7 +598,6 @@ PHP_RSHUTDOWN_FUNCTION(pgsql)
605
598
{
606
599
/* clean up notice messages */
607
600
zend_hash_clean (& PGG (notices ));
608
- zend_hash_clean (& PGG (hashes ));
609
601
zend_hash_clean (& PGG (regular_list ));
610
602
/* clean up persistent connection */
611
603
zend_hash_apply (& EG (persistent_list ), (apply_func_t ) _rollback_transactions );
@@ -769,6 +761,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
769
761
object_init_ex (return_value , pgsql_link_ce );
770
762
link = Z_PGSQL_LINK_P (return_value );
771
763
link -> conn = pgsql ;
764
+ link -> hash = zend_string_copy (str .s );
772
765
773
766
/* add it to the hash */
774
767
ZVAL_COPY (& new_index_ptr , return_value );
@@ -778,11 +771,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
778
771
* when the connection is closed. This uses the address of the connection rather than the
779
772
* zend_resource, because the resource destructor is passed a stack copy of the resource
780
773
* structure. */
781
- {
782
- zval tmp ;
783
- ZVAL_STR_COPY (& tmp , str .s );
784
- zend_hash_index_update (& PGG (hashes ), (uintptr_t ) pgsql , & tmp );
785
- }
774
+
786
775
PGG (num_links )++ ;
787
776
}
788
777
/* set notice processor */
0 commit comments