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.
Dependents: iSerial DGWWebServer iSerial Dumb_box_rev2 ... more
Diff: RingBuffer.cpp
- Revision:
- 2:ea6d02ba96ae
- Parent:
- 1:1c3a10f2eb04
diff -r 1c3a10f2eb04 -r ea6d02ba96ae RingBuffer.cpp
--- a/RingBuffer.cpp Fri Aug 31 17:13:40 2012 +0000
+++ b/RingBuffer.cpp Thu Sep 27 13:15:54 2012 +0000
@@ -18,8 +18,7 @@
: bufsize(_bufsize)
{
buf = new unsigned char [bufsize+1];
-
- sp = ep = (unsigned int)buf;
+ sp = ep = buf;
memset(buf,0,bufsize);
}
@@ -32,15 +31,16 @@
RingBuffer::save(unsigned char c)
{
if( (ep==sp-1)||
- ((sp==(unsigned int)buf)&&
- (ep==(unsigned int)buf+bufsize-1)) ) /* buffer full */
+ ((sp==buf)&&
+ (ep==buf+bufsize-1)) ) /* buffer full */
return 0;
- *(unsigned char*)ep = c;
+ *ep = c;
ep++;
- if(ep > (unsigned int)buf+bufsize)
- ep = (unsigned int)buf;
+ if(ep > buf+bufsize)
+ ep = buf;
+
return 1;
}
@@ -52,12 +52,13 @@
if(sp == ep)
return 0; /* buffer empty */
- ret = *(unsigned char*)sp;
- *(unsigned char*)sp = 0;
+ ret = *sp;
+ *sp = 0;
sp++;
- if(sp> (unsigned int)buf+bufsize)
- sp = (unsigned int)buf;
+ if(sp > buf+bufsize)
+ sp = buf;
+
return ret;
}