@@ -169,7 +169,7 @@ static void pgsql_link_free(pgsql_link_handle *link)
169169 }
170170 PGG (num_links )-- ;
171171
172- zend_hash_del (& PGG (regular_list ), link -> hash );
172+ zend_hash_del (& PGG (connections ), link -> hash );
173173
174174 link -> conn = NULL ;
175175 zend_string_release (link -> hash );
@@ -257,7 +257,6 @@ static void pgsql_lob_free_obj(zend_object *obj)
257257
258258 zend_object_std_dtor (& lofp -> std );
259259}
260- static int le_link , le_plink , le_result , le_lofp ;
261260
262261/* Compatibility definitions */
263262
@@ -286,6 +285,8 @@ static zend_string *_php_pgsql_trim_message(const char *message)
286285
287286static void php_pgsql_set_default_link (pgsql_link_handle * link )
288287{
288+ GC_ADDREF (res );
289+
289290 PGG (default_link ) = link ;
290291}
291292
@@ -312,10 +313,9 @@ static void _php_pgsql_notice_handler(void *l, const char *message)
312313 }
313314
314315 pgsql_link_handle * link ;
315- HashTable * notices , tmp_notices ;
316316 zval tmp ;
317317
318- link = (( pgsql_link_handle * ) l ) ;
318+ link = (pgsql_link_handle * ) l ;
319319 if (!link -> notices ) {
320320 link -> notices = zend_new_array (1 );
321321 }
@@ -325,7 +325,8 @@ static void _php_pgsql_notice_handler(void *l, const char *message)
325325 php_error_docref (NULL , E_NOTICE , "%s" , ZSTR_VAL (trimmed_message ));
326326 }
327327
328- add_next_index_str (link -> notices , trimmed_message );
328+ ZVAL_STR (& tmp , trimmed_message );
329+ zend_hash_next_index_insert (link -> notices , & tmp );
329330}
330331
331332static int _rollback_transactions (zval * el )
@@ -359,12 +360,6 @@ static int _rollback_transactions(zval *el)
359360 return ZEND_HASH_APPLY_KEEP ;
360361}
361362
362- static void _free_ptr (zend_resource * rsrc )
363- {
364- pgLofp * lofp = (pgLofp * )rsrc -> ptr ;
365- efree (lofp );
366- }
367-
368363static void release_string (zval * zv )
369364{
370365 zend_string_release ((zend_string * ) Z_PTR_P (zv ));
@@ -409,7 +404,7 @@ static PHP_GINIT_FUNCTION(pgsql)
409404 ZEND_TSRMLS_CACHE_UPDATE ();
410405#endif
411406 memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
412- zend_hash_init (& pgsql_globals -> regular_list , 0 , NULL , ZVAL_PTR_DTOR , 1 );
407+ zend_hash_init (& pgsql_globals -> connections , 0 , NULL , ZVAL_PTR_DTOR , 1 );
413408}
414409
415410static void php_libpq_version (char * buf , size_t len )
@@ -434,7 +429,7 @@ PHP_MINIT_FUNCTION(pgsql)
434429
435430 le_plink = zend_register_list_destructors_ex (NULL , _close_pgsql_plink , "pgsql link persistent" , module_number );
436431
437- pgsql_link_ce = register_class_PgSql ();
432+ pgsql_link_ce = register_class_PgSql_Connection ();
438433 pgsql_link_ce -> create_object = pgsql_link_create_object ;
439434 pgsql_link_ce -> serialize = zend_class_serialize_deny ;
440435 pgsql_link_ce -> unserialize = zend_class_unserialize_deny ;
@@ -446,7 +441,7 @@ PHP_MINIT_FUNCTION(pgsql)
446441 pgsql_link_object_handlers .clone_obj = NULL ;
447442 pgsql_link_object_handlers .compare = zend_objects_not_comparable ;
448443
449- pgsql_result_ce = register_class_PgSqlResult ();
444+ pgsql_result_ce = register_class_PgSql_Result ();
450445 pgsql_result_ce -> create_object = pgsql_result_create_object ;
451446 pgsql_result_ce -> serialize = zend_class_serialize_deny ;
452447 pgsql_result_ce -> unserialize = zend_class_unserialize_deny ;
@@ -458,7 +453,7 @@ PHP_MINIT_FUNCTION(pgsql)
458453 pgsql_result_object_handlers .clone_obj = NULL ;
459454 pgsql_result_object_handlers .compare = zend_objects_not_comparable ;
460455
461- pgsql_lob_ce = register_class_PgSqlLob ();
456+ pgsql_lob_ce = register_class_PgSql_Lob ();
462457 pgsql_lob_ce -> create_object = pgsql_lob_create_object ;
463458 pgsql_lob_ce -> serialize = zend_class_serialize_deny ;
464459 pgsql_lob_ce -> unserialize = zend_class_unserialize_deny ;
@@ -579,7 +574,7 @@ PHP_MINIT_FUNCTION(pgsql)
579574PHP_MSHUTDOWN_FUNCTION (pgsql )
580575{
581576 UNREGISTER_INI_ENTRIES ();
582- zend_hash_destroy (& PGG (regular_list ));
577+ zend_hash_destroy (& PGG (connections ));
583578
584579 return SUCCESS ;
585580}
@@ -726,7 +721,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
726721 * and add a pointer to it with hashed_details as the key.
727722 */
728723 if (!(connect_type & PGSQL_CONNECT_FORCE_NEW )
729- && (index_ptr = zend_hash_find_ptr (& PGG (regular_list ), str .s )) != NULL ) {
724+ && (index_ptr = zend_hash_find_ptr (& PGG (connections ), str .s )) != NULL ) {
730725 php_pgsql_set_default_link (pgsql_link_from_obj (Z_OBJ_P (index_ptr )));
731726 GC_ADDREF (Z_OBJ_P (index_ptr ));
732727 ZVAL_COPY (return_value , index_ptr );
@@ -768,9 +763,9 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
768763
769764 /* add it to the hash */
770765 ZVAL_COPY (& new_index_ptr , return_value );
771- zend_hash_update (& PGG (regular_list ), str .s , & new_index_ptr );
766+ zend_hash_update (& PGG (connections ), str .s , & new_index_ptr );
772767
773- /* Keep track of link => hash mapping, so we can remove the hash entry from regular_list
768+ /* Keep track of link => hash mapping, so we can remove the hash entry from connections
774769 * when the connection is closed. This uses the address of the connection rather than the
775770 * zend_resource, because the resource destructor is passed a stack copy of the resource
776771 * structure. */
@@ -842,7 +837,7 @@ PHP_FUNCTION(pg_close)
842837 if (!pgsql_link ) {
843838 link = FETCH_DEFAULT_LINK ();
844839 CHECK_DEFAULT_LINK (link );
845- zend_hash_del (& PGG (regular_list ), link -> hash );
840+ zend_hash_del (& PGG (connections ), link -> hash );
846841 PGG (default_link ) = NULL ;
847842 RETURN_TRUE ;
848843 }
@@ -851,7 +846,7 @@ PHP_FUNCTION(pg_close)
851846 CHECK_PGSQL_LINK (link );
852847
853848 if (link == FETCH_DEFAULT_LINK ()) {
854- zend_hash_del (& PGG (regular_list ), link -> hash );
849+ zend_hash_del (& PGG (connections ), link -> hash );
855850 PGG (default_link ) = NULL ;
856851 }
857852 pgsql_link_free (link );
0 commit comments