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