Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
Diff: CircularBuf.cpp
- Revision:
- 32:c40d581f50af
- Parent:
- 31:39d04aedc3e5
--- a/CircularBuf.cpp Mon Apr 23 15:29:18 2018 +0000 +++ b/CircularBuf.cpp Mon Apr 23 16:05:32 2018 +0000 @@ -2,7 +2,7 @@ #include "stdio.h" template <typename T> -CircularBuf<T>::CircularBuf(unsigned int size) : _size(size), _head(size), _tail(size) { +CircularBuf<T>::CircularBuf(unsigned int size) : _size(size), _head(0), _tail(0) { _data = (T*)malloc(sizeof(T) * size); } @@ -21,7 +21,7 @@ if (next >= _size) next = 0; - if (next == _tail) + if (next == _tail) return cnt; _data[next] = data[cnt]; @@ -43,7 +43,7 @@ next = 0; } - if (next > _head) + if (_tail == _head) return cnt; data[cnt] = _data[next];