pairing heap free link list gets orphaned when fully depleted (#1120) (#1121)

add some more asserts, and fix test case for debug which was broken by all the assserts slowing it down
This commit is contained in:
Graham Sanderson 2022-12-08 11:14:53 -06:00 committed by GitHub
parent 0b52603667
commit 605e21ae6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -247,6 +247,10 @@ static inline void ph_free_node(pheap_t *heap, pheap_node_id_t id) {
if (heap->free_tail_id) { if (heap->free_tail_id) {
ph_get_node(heap, heap->free_tail_id)->sibling = id; ph_get_node(heap, heap->free_tail_id)->sibling = id;
} }
if (!heap->free_head_id) {
assert(!heap->free_tail_id);
heap->free_head_id = id;
}
heap->free_tail_id = id; heap->free_tail_id = id;
} }

View File

@ -62,6 +62,10 @@ static pheap_node_id_t ph_remove_any_head(pheap_t *heap, pheap_node_id_t root_id
if (heap->free_tail_id) { if (heap->free_tail_id) {
ph_get_node(heap, heap->free_tail_id)->sibling = root_id; ph_get_node(heap, heap->free_tail_id)->sibling = root_id;
} }
if (!heap->free_head_id) {
assert(!heap->free_tail_id);
heap->free_head_id = root_id;
}
heap->free_tail_id = root_id; heap->free_tail_id = root_id;
} }
if (new_root_id) ph_get_node(heap, new_root_id)->parent = 0; if (new_root_id) ph_get_node(heap, new_root_id)->parent = 0;

View File

@ -18,7 +18,11 @@ PICOTEST_MODULE_NAME("pico_time_test", "pico_time test harness");
static_assert(PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS >= MAX_TIMERS_PER_POOL, ""); static_assert(PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS >= MAX_TIMERS_PER_POOL, "");
#define TEST_LENGTH_US 2000000 #define TEST_LENGTH_US 2000000
#ifndef NDEBUG
#define NUM_REPEATING_TIMERS 30
#else
#define NUM_REPEATING_TIMERS 50 #define NUM_REPEATING_TIMERS 50
#endif
static struct repeating_timer repeating_timers[NUM_REPEATING_TIMERS]; static struct repeating_timer repeating_timers[NUM_REPEATING_TIMERS];
static uint repeating_timer_callback_count[NUM_REPEATING_TIMERS]; static uint repeating_timer_callback_count[NUM_REPEATING_TIMERS];