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.
Fork of Buffer by
Diff: Buffer.cpp
- Revision:
- 2:d13a72146516
- Parent:
- 1:490224f41c09
- Child:
- 4:cd0a1f4c623f
diff -r 490224f41c09 -r d13a72146516 Buffer.cpp
--- a/Buffer.cpp Thu May 23 19:26:31 2013 +0000
+++ b/Buffer.cpp Thu May 23 23:48:36 2013 +0000
@@ -27,7 +27,7 @@
Buffer<T>::Buffer(BUFFER_SIZE size)
{
_buf = new T [size];
- _size = size;
+ _sizemask = size-1;
clear();
return;
@@ -45,7 +45,7 @@
void Buffer<T>::put(T data)
{
_buf[_wloc++] = data;
- _wloc &= (_size-1);
+ _wloc &= _sizemask;
return;
}
@@ -54,7 +54,7 @@
T Buffer<T>::get(void)
{
T data_pos = _buf[_rloc++];
- _rloc &= (_size-1);
+ _rloc &= _sizemask;
return data_pos;
}
@@ -72,7 +72,7 @@
{
_wloc = 0;
_rloc = 0;
- memset(_buf, 0, _size);
+ memset(_buf, 0, _sizemask+1);
return;
}
@@ -83,6 +83,14 @@
return (_wloc == _rloc) ? 0 : 1;
}
+template <class T>
+uint32_t Buffer<T>::peek(char c)
+{
+ return 1;
+}
+
+
+
// make the linker aware of some possible types
template class Buffer<uint8_t>;
template class Buffer<int8_t>;
