Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct _spl_ptr_heap {
spl_ptr_heap_ctor_func ctor;
spl_ptr_heap_dtor_func dtor;
spl_ptr_heap_cmp_func cmp;
int count;
size_t count;
int flags;
size_t max_size;
size_t elem_size;
Expand Down Expand Up @@ -267,7 +267,7 @@ static spl_ptr_heap *spl_ptr_heap_init(spl_ptr_heap_cmp_func cmp, spl_ptr_heap_c
/* }}} */

static void spl_ptr_heap_insert(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
int i;
size_t i;

if (heap->count+1 > heap->max_size) {
size_t alloc_size = heap->max_size * heap->elem_size;
Expand Down Expand Up @@ -306,8 +306,8 @@ static void *spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
/* }}} */

static zend_result spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
int i, j;
const int limit = (heap->count-1)/2;
size_t i, j;
const size_t limit = (heap->count-1)/2;
void *bottom;

if (heap->count == 0) {
Expand Down Expand Up @@ -355,8 +355,6 @@ static zend_result spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *elem, void
/* }}} */

static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from) { /* {{{ */
int i;

spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));

heap->dtor = from->dtor;
Expand All @@ -370,7 +368,7 @@ static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from) { /* {{{ */
heap->elements = safe_emalloc(from->elem_size, from->max_size, 0);
memcpy(heap->elements, from->elements, from->elem_size * from->max_size);

for (i = 0; i < heap->count; ++i) {
for (size_t i = 0; i < heap->count; ++i) {
heap->ctor(spl_heap_elem(heap, i));
}

Expand All @@ -384,11 +382,9 @@ static void spl_ptr_heap_destroy(spl_ptr_heap *heap) { /* {{{ */
return;
}

int i;

heap->flags |= SPL_HEAP_WRITE_LOCKED;

for (i = 0; i < heap->count; ++i) {
for (size_t i = 0; i < heap->count; ++i) {
heap->dtor(spl_heap_elem(heap, i));
}

Expand All @@ -399,7 +395,7 @@ static void spl_ptr_heap_destroy(spl_ptr_heap *heap) { /* {{{ */
}
/* }}} */

static int spl_ptr_heap_count(spl_ptr_heap *heap) { /* {{{ */
static size_t spl_ptr_heap_count(spl_ptr_heap *heap) { /* {{{ */
return heap->count;
}
/* }}} */
Expand Down Expand Up @@ -534,7 +530,7 @@ static HashTable* spl_heap_object_get_debug_info(const zend_class_entry *ce, zen

array_init(&heap_array);

for (zend_ulong i = 0; i < intern->heap->count; ++i) {
for (size_t i = 0; i < intern->heap->count; ++i) {
if (ce == spl_ce_SplPriorityQueue) {
spl_pqueue_elem *pq_elem = spl_heap_elem(intern->heap, i);
zval elem;
Expand Down
Loading