如果申请空间不足,申请不到合适的空间,需要回收new_rbb

This commit is contained in:
winfenggao 2024-05-22 19:12:06 +08:00 committed by Rbb666
parent 2cc2743fc7
commit 80dc539698
1 changed files with 15 additions and 8 deletions

View File

@ -215,6 +215,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
else
{
/* no space */
rt_slist_insert(&rbb->free_list, &new_rbb->list);
new_rbb = RT_NULL;
}
}
@ -239,6 +240,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
else
{
/* no space */
rt_slist_insert(&rbb->free_list, &new_rbb->list);
new_rbb = RT_NULL;
}
}
@ -246,16 +248,21 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
else
{
/* the list is empty */
list_append(rbb, &new_rbb->list);
new_rbb->status = RT_RBB_BLK_INITED;
new_rbb->buf = rbb->buf;
new_rbb->size = blk_size;
if(blk_size <= rbb->buf_size)
{
list_append(rbb, &new_rbb->list);
new_rbb->status = RT_RBB_BLK_INITED;
new_rbb->buf = rbb->buf;
new_rbb->size = blk_size;
}
else
{
/* no space */
rt_slist_insert(&rbb->free_list, &new_rbb->list);
new_rbb = RT_NULL;
}
}
}
else
{
new_rbb = RT_NULL;
}
rt_spin_unlock_irqrestore(&(rbb->spinlock), level);