@@ -2229,6 +2229,42 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */
2229
2229
}
2230
2230
/* }}} */
2231
2231
2232
+ static HashTable * php_sqlite3_get_gc (zend_object * object , zval * * table , int * n )
2233
+ {
2234
+ php_sqlite3_db_object * intern = php_sqlite3_db_from_obj (object );
2235
+
2236
+ if (intern -> funcs == NULL && intern -> collations == NULL ) {
2237
+ /* Fast path without allocations */
2238
+ * table = NULL ;
2239
+ * n = 0 ;
2240
+ return zend_std_get_gc (object , table , n );
2241
+ } else {
2242
+ zend_get_gc_buffer * gc_buffer = zend_get_gc_buffer_create ();
2243
+
2244
+ php_sqlite3_func * func = intern -> funcs ;
2245
+ while (func != NULL ) {
2246
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> func );
2247
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> step );
2248
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> fini );
2249
+ func = func -> next ;
2250
+ }
2251
+
2252
+ php_sqlite3_collation * collation = intern -> collations ;
2253
+ while (collation != NULL ) {
2254
+ zend_get_gc_buffer_add_zval (gc_buffer , & collation -> cmp_func );
2255
+ collation = collation -> next ;
2256
+ }
2257
+
2258
+ zend_get_gc_buffer_use (gc_buffer , table , n );
2259
+
2260
+ if (object -> properties == NULL && object -> ce -> default_properties_count == 0 ) {
2261
+ return NULL ;
2262
+ } else {
2263
+ return zend_std_get_properties (object );
2264
+ }
2265
+ }
2266
+ }
2267
+
2232
2268
static void php_sqlite3_stmt_object_free_storage (zend_object * object ) /* {{{ */
2233
2269
{
2234
2270
php_sqlite3_stmt * intern = php_sqlite3_stmt_from_obj (object );
@@ -2364,6 +2400,7 @@ PHP_MINIT_FUNCTION(sqlite3)
2364
2400
sqlite3_object_handlers .offset = XtOffsetOf (php_sqlite3_db_object , zo );
2365
2401
sqlite3_object_handlers .clone_obj = NULL ;
2366
2402
sqlite3_object_handlers .free_obj = php_sqlite3_object_free_storage ;
2403
+ sqlite3_object_handlers .get_gc = php_sqlite3_get_gc ;
2367
2404
php_sqlite3_sc_entry = register_class_SQLite3 ();
2368
2405
php_sqlite3_sc_entry -> create_object = php_sqlite3_object_new ;
2369
2406
0 commit comments