Skip to content

Commit

Permalink
Fix priorty-heap-iter function
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Seo committed Dec 31, 2024
1 parent d8766d1 commit f7834a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/data_structures/priority_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void simple_archiver_priority_heap_iter(SDArchiverPHeap *priority_heap,
if (priority_heap->size == 0) {
return;
}
for (uint64_t idx = 0; idx < priority_heap->size; ++idx) {
for (uint64_t idx = 0; idx < priority_heap->capacity; ++idx) {
if (priority_heap->nodes[idx].is_valid) {
iter_fn(priority_heap->nodes[idx].data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/data_structures/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ int main(void) {
simple_archiver_priority_heap_free(&priority_heap);

priority_heap = simple_archiver_priority_heap_init();
for (uint32_t idx = 0; idx < 50; ++idx) {
for (uint32_t idx = 0; idx < 15; ++idx) {
uint32_t *data = malloc(sizeof(uint32_t));
*data = idx;
simple_archiver_priority_heap_insert(priority_heap, idx, data, NULL);
}
printf("Begin iteration of 50 elements:\n");
printf("Begin iteration of 15 elements:\n");

simple_archiver_priority_heap_iter(priority_heap,
test_iter_fn_priority_heap);
Expand Down

0 comments on commit f7834a7

Please sign in to comment.