fix: handle NULL from realloc

master
Sean McBride 3 years ago
parent 3b92963868
commit 3aaa7737df

@ -292,7 +292,7 @@ priority_queue_initialize(size_t capacity, bool use_lock, priority_queue_get_pri
* unclear if the fact that the lock is a member in the struct that might be moved by realloc breaks the guarantees of
* the lock.
* @param priority_queue to resize
* @returns pointer to PR. This may have been moved by realloc!
* @returns pointer to PR or NULL if realloc fails. This may have been moved by realloc!
*/
static inline struct priority_queue *
priority_queue_grow_nolock(struct priority_queue *priority_queue)

@ -37,7 +37,9 @@ local_runqueue_minheap_add(struct sandbox *sandbox)
{
int return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox);
if (unlikely(return_code == -ENOSPC)) {
local_runqueue_minheap = priority_queue_grow_nolock(local_runqueue_minheap);
struct priority_queue *temp = priority_queue_grow_nolock(local_runqueue_minheap);
if (unlikely(temp == NULL)) panic("Failed to grow local runqueue\n");
local_runqueue_minheap = temp;
return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox);
if (unlikely(return_code == -ENOSPC)) panic("Thread Runqueue is full!\n");
}

Loading…
Cancel
Save