@@ -2245,6 +2245,42 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */
2245
2245
}
2246
2246
/* }}} */
2247
2247
2248
+ static HashTable * php_sqlite3_get_gc (zend_object * object , zval * * table , int * n )
2249
+ {
2250
+ php_sqlite3_db_object * intern = php_sqlite3_db_from_obj (object );
2251
+
2252
+ if (intern -> funcs == NULL && intern -> collations == NULL ) {
2253
+ /* Fast path without allocations */
2254
+ * table = NULL ;
2255
+ * n = 0 ;
2256
+ return zend_std_get_gc (object , table , n );
2257
+ } else {
2258
+ zend_get_gc_buffer * gc_buffer = zend_get_gc_buffer_create ();
2259
+
2260
+ php_sqlite3_func * func = intern -> funcs ;
2261
+ while (func != NULL ) {
2262
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> func );
2263
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> step );
2264
+ zend_get_gc_buffer_add_zval (gc_buffer , & func -> fini );
2265
+ func = func -> next ;
2266
+ }
2267
+
2268
+ php_sqlite3_collation * collation = intern -> collations ;
2269
+ while (collation != NULL ) {
2270
+ zend_get_gc_buffer_add_zval (gc_buffer , & collation -> cmp_func );
2271
+ collation = collation -> next ;
2272
+ }
2273
+
2274
+ zend_get_gc_buffer_use (gc_buffer , table , n );
2275
+
2276
+ if (object -> properties == NULL && object -> ce -> default_properties_count == 0 ) {
2277
+ return NULL ;
2278
+ } else {
2279
+ return zend_std_get_properties (object );
2280
+ }
2281
+ }
2282
+ }
2283
+
2248
2284
static void php_sqlite3_stmt_object_free_storage (zend_object * object ) /* {{{ */
2249
2285
{
2250
2286
php_sqlite3_stmt * intern = php_sqlite3_stmt_from_obj (object );
@@ -2377,6 +2413,7 @@ PHP_MINIT_FUNCTION(sqlite3)
2377
2413
sqlite3_object_handlers .offset = XtOffsetOf (php_sqlite3_db_object , zo );
2378
2414
sqlite3_object_handlers .clone_obj = NULL ;
2379
2415
sqlite3_object_handlers .free_obj = php_sqlite3_object_free_storage ;
2416
+ sqlite3_object_handlers .get_gc = php_sqlite3_get_gc ;
2380
2417
php_sqlite3_sc_entry = register_class_SQLite3 ();
2381
2418
php_sqlite3_sc_entry -> create_object = php_sqlite3_object_new ;
2382
2419
php_sqlite3_sc_entry -> default_object_handlers = & sqlite3_object_handlers ;
0 commit comments