@@ -163,22 +163,17 @@ static zend_function *pgsql_link_get_constructor(zend_object *object) {
163163static void pgsql_link_free (pgsql_link_handle * link )
164164{
165165 PGresult * res ;
166- zval * hash ;
167166
168167 while ((res = PQgetResult (link -> conn ))) {
169168 PQclear (res );
170169 }
171170 PQfinish (link -> conn );
172171 PGG (num_links )-- ;
173172
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 );
180174
181175 link -> conn = NULL ;
176+ zend_string_release (link -> hash );
182177}
183178
184179static void pgsql_link_free_obj (zend_object * obj )
@@ -415,7 +410,6 @@ static PHP_GINIT_FUNCTION(pgsql)
415410 memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
416411 /* Initialize notice message hash at MINIT only */
417412 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 );
419413 zend_hash_init (& pgsql_globals -> regular_list , 0 , NULL , ZVAL_PTR_DTOR , 1 );
420414}
421415
@@ -588,7 +582,6 @@ PHP_MSHUTDOWN_FUNCTION(pgsql)
588582{
589583 UNREGISTER_INI_ENTRIES ();
590584 zend_hash_destroy (& PGG (notices ));
591- zend_hash_destroy (& PGG (hashes ));
592585 zend_hash_destroy (& PGG (regular_list ));
593586
594587 return SUCCESS ;
@@ -605,7 +598,6 @@ PHP_RSHUTDOWN_FUNCTION(pgsql)
605598{
606599 /* clean up notice messages */
607600 zend_hash_clean (& PGG (notices ));
608- zend_hash_clean (& PGG (hashes ));
609601 zend_hash_clean (& PGG (regular_list ));
610602 /* clean up persistent connection */
611603 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)
769761 object_init_ex (return_value , pgsql_link_ce );
770762 link = Z_PGSQL_LINK_P (return_value );
771763 link -> conn = pgsql ;
764+ link -> hash = zend_string_copy (str .s );
772765
773766 /* add it to the hash */
774767 ZVAL_COPY (& new_index_ptr , return_value );
@@ -778,11 +771,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
778771 * when the connection is closed. This uses the address of the connection rather than the
779772 * zend_resource, because the resource destructor is passed a stack copy of the resource
780773 * 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+
786775 PGG (num_links )++ ;
787776 }
788777 /* set notice processor */
0 commit comments