4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-03-04 00:15:30 +08:00

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

This commit is contained in:
winfenggao 2024-05-22 19:12:06 +08:00 committed by Rbb666
parent 2cc2743fc7
commit 80dc539698

View File

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