如果申请空间不足,申请不到合适的空间,需要回收new_rbb
This commit is contained in:
parent
2cc2743fc7
commit
80dc539698
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue