@@ -248,8 +248,6 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, zval *elem, void *cmp_userda
248
248
heap -> max_size *= 2 ;
249
249
}
250
250
251
- heap -> ctor (elem );
252
-
253
251
/* sifting up */
254
252
for (i = heap -> count ++ ; i > 0 && heap -> cmp (& heap -> elements [(i - 1 )/2 ], elem , cmp_userdata ) < 0 ; i = (i - 1 )/2 ) {
255
253
heap -> elements [i ] = heap -> elements [(i - 1 )/2 ];
@@ -307,7 +305,6 @@ static void spl_ptr_heap_delete_top(spl_ptr_heap *heap, zval *elem, void *cmp_us
307
305
}
308
306
309
307
ZVAL_COPY_VALUE (& heap -> elements [i ], bottom );
310
- heap -> dtor (elem );
311
308
}
312
309
/* }}} */
313
310
@@ -350,23 +347,15 @@ static int spl_ptr_heap_count(spl_ptr_heap *heap) { /* {{{ */
350
347
return heap -> count ;
351
348
}
352
349
/* }}} */
353
- /* }}} */
354
350
355
351
zend_object_iterator * spl_heap_get_iterator (zend_class_entry * ce , zval * object , int by_ref );
356
352
357
353
static void spl_heap_object_free_storage (zend_object * object ) /* {{{ */
358
354
{
359
- int i ;
360
355
spl_heap_object * intern = spl_heap_from_obj (object );
361
356
362
357
zend_object_std_dtor (& intern -> std );
363
358
364
- for (i = 0 ; i < intern -> heap -> count ; ++ i ) {
365
- if (!Z_ISUNDEF (intern -> heap -> elements [i ])) {
366
- zval_ptr_dtor (& intern -> heap -> elements [i ]);
367
- }
368
- }
369
-
370
359
spl_ptr_heap_destroy (intern -> heap );
371
360
}
372
361
/* }}} */
@@ -496,7 +485,7 @@ static int spl_heap_object_count_elements(zval *object, zend_long *count) /* {{{
496
485
/* }}} */
497
486
498
487
static HashTable * spl_heap_object_get_debug_info_helper (zend_class_entry * ce , zval * obj , int * is_temp ) { /* {{{ */
499
- spl_heap_object * intern = Z_SPLHEAP_P (obj );
488
+ spl_heap_object * intern = Z_SPLHEAP_P (obj );
500
489
zval tmp , heap_array ;
501
490
zend_string * pnstr ;
502
491
HashTable * debug_info ;
@@ -539,6 +528,16 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
539
528
}
540
529
/* }}} */
541
530
531
+ static HashTable * spl_heap_object_get_gc (zval * obj , zval * * gc_data , int * gc_data_count ) /* {{{ */
532
+ {
533
+ spl_heap_object * intern = Z_SPLHEAP_P (obj );
534
+ * gc_data = intern -> heap -> elements ;
535
+ * gc_data_count = intern -> heap -> count ;
536
+
537
+ return std_object_handlers .get_properties (obj );
538
+ }
539
+ /* }}} */
540
+
542
541
static HashTable * spl_heap_object_get_debug_info (zval * obj , int * is_temp ) /* {{{ */
543
542
{
544
543
return spl_heap_object_get_debug_info_helper (spl_ce_SplHeap , obj , is_temp );
@@ -610,7 +609,6 @@ SPL_METHOD(SplHeap, insert)
610
609
extract the element out of the top of the heap */
611
610
SPL_METHOD (SplHeap , extract )
612
611
{
613
- zval value ;
614
612
spl_heap_object * intern ;
615
613
616
614
if (zend_parse_parameters_none () == FAILURE ) {
@@ -624,14 +622,12 @@ SPL_METHOD(SplHeap, extract)
624
622
return ;
625
623
}
626
624
627
- spl_ptr_heap_delete_top (intern -> heap , & value , getThis ());
625
+ spl_ptr_heap_delete_top (intern -> heap , return_value , getThis ());
628
626
629
- if (Z_ISUNDEF ( value )) {
627
+ if (Z_ISUNDEF_P ( return_value )) {
630
628
zend_throw_exception (spl_ce_RuntimeException , "Can't extract from an empty heap" , 0 );
631
629
return ;
632
630
}
633
-
634
- RETURN_ZVAL (& value , 1 , 1 );
635
631
}
636
632
/* }}} */
637
633
@@ -1216,6 +1212,7 @@ PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
1216
1212
spl_handler_SplHeap .clone_obj = spl_heap_object_clone ;
1217
1213
spl_handler_SplHeap .count_elements = spl_heap_object_count_elements ;
1218
1214
spl_handler_SplHeap .get_debug_info = spl_heap_object_get_debug_info ;
1215
+ spl_handler_SplHeap .get_gc = spl_heap_object_get_gc ;
1219
1216
spl_handler_SplHeap .dtor_obj = zend_objects_destroy_object ;
1220
1217
spl_handler_SplHeap .free_obj = spl_heap_object_free_storage ;
1221
1218
@@ -1237,6 +1234,7 @@ PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
1237
1234
spl_handler_SplPriorityQueue .clone_obj = spl_heap_object_clone ;
1238
1235
spl_handler_SplPriorityQueue .count_elements = spl_heap_object_count_elements ;
1239
1236
spl_handler_SplPriorityQueue .get_debug_info = spl_pqueue_object_get_debug_info ;
1237
+ spl_handler_SplPriorityQueue .get_gc = spl_heap_object_get_gc ;
1240
1238
spl_handler_SplPriorityQueue .dtor_obj = zend_objects_destroy_object ;
1241
1239
spl_handler_SplPriorityQueue .free_obj = spl_heap_object_free_storage ;
1242
1240
0 commit comments