• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "buf_fifo.h"
10 
BufferFifoInit(struct BufferFifo * fifo,uint8_t * fifoBuffer,uint16_t fifoSize)11 bool BufferFifoInit(struct BufferFifo *fifo, uint8_t *fifoBuffer, uint16_t fifoSize)
12 {
13     if (fifoBuffer == NULL) {
14         return false;
15     }
16     if (!IsPowerOfTwo(fifoSize)) {
17         return false;
18     }
19     fifo->buffer = fifoBuffer;
20     fifo->bufSizeMask = fifoSize - 1;
21     fifo->readPosition = 0;
22     fifo->writePosition = 0;
23     return true;
24 }