@@ -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 )
@@ -406,7 +401,6 @@ static PHP_GINIT_FUNCTION(pgsql)
406
401
memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
407
402
/* Initialize notice message hash at MINIT only */
408
403
zend_hash_init (& pgsql_globals -> notices , 0 , NULL , ZVAL_PTR_DTOR , 1 );
409
- zend_hash_init (& pgsql_globals -> hashes , 0 , NULL , ZVAL_PTR_DTOR , 1 );
410
404
zend_hash_init (& pgsql_globals -> regular_list , 0 , NULL , ZVAL_PTR_DTOR , 1 );
411
405
}
412
406
@@ -578,7 +572,6 @@ PHP_MSHUTDOWN_FUNCTION(pgsql)
578
572
{
579
573
UNREGISTER_INI_ENTRIES ();
580
574
zend_hash_destroy (& PGG (notices ));
581
- zend_hash_destroy (& PGG (hashes ));
582
575
zend_hash_destroy (& PGG (regular_list ));
583
576
584
577
return SUCCESS ;
@@ -763,6 +756,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
763
756
object_init_ex (return_value , pgsql_link_ce );
764
757
link = Z_PGSQL_LINK_P (return_value );
765
758
link -> conn = pgsql ;
759
+ link -> hash = zend_string_copy (str .s );
766
760
767
761
/* add it to the hash */
768
762
ZVAL_COPY (& new_index_ptr , return_value );
@@ -772,11 +766,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
772
766
* when the connection is closed. This uses the address of the connection rather than the
773
767
* zend_resource, because the resource destructor is passed a stack copy of the resource
774
768
* structure. */
775
- {
776
- zval tmp ;
777
- ZVAL_STR_COPY (& tmp , str .s );
778
- zend_hash_index_update (& PGG (hashes ), (uintptr_t ) pgsql , & tmp );
779
- }
769
+
780
770
PGG (num_links )++ ;
781
771
}
782
772
/* set notice processor */
0 commit comments