修改摧毁fifo时返回机制

This commit is contained in:
2025-08-15 20:22:38 +08:00
parent 966fed011c
commit ad69466fb4

View File

@@ -107,7 +107,7 @@ bool kfifo_destroy(kfifo_t *fifo) {
if (fifo) {
if(fifo->pool == NULL) {
free(fifo); // 如果 pool 已经是 NULL直接释放 fifo
return false; // 如果 pool 已经是 NULL直接返回
return true; // 如果 pool 已经是 NULL直接返回
}
free(fifo->pool);
fifo->pool = NULL; // 清空指针,避免悬挂指针
@@ -296,7 +296,6 @@ int kfifo_peek_seek(kfifo_t *fifo, const uint8_t **ptr, uint32_t seek) {
return 0;
}
// *ptr = &KFIFO_POOL_PTR(fifo)[kfifo_offset_seek_out(fifo, seek)];
*ptr = (uint8_t*)fifo->pool + kfifo_offset_seek_out(fifo, seek);
if (kfifo_remain_out(fifo) > seek) {
seek = kfifo_remain_seek_out(fifo, seek);