From 80dc539698b7f40be8740edef42ff002d01b17bc Mon Sep 17 00:00:00 2001 From: winfenggao Date: Wed, 22 May 2024 19:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=94=B3=E8=AF=B7=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E4=B8=8D=E8=B6=B3=EF=BC=8C=E7=94=B3=E8=AF=B7=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E5=90=88=E9=80=82=E7=9A=84=E7=A9=BA=E9=97=B4=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9B=9E=E6=94=B6new=5Frbb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/ipc/ringblk_buf.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/components/drivers/ipc/ringblk_buf.c b/components/drivers/ipc/ringblk_buf.c index ab160270c4..6196747838 100644 --- a/components/drivers/ipc/ringblk_buf.c +++ b/components/drivers/ipc/ringblk_buf.c @@ -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);