Skip to content

Commit 3e419dd

Browse files
authored
Syntax highlighting
1 parent d62e9e0 commit 3e419dd

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ I decided to give object oriented programming a shot using only C (no C++) with
1717

1818
Fine. I reluctantly wrapped the C stuff in a C++ class called `RingBufC`. All the methods are the same, except you no longer have to pass the this/self pointer. You can use either.
1919

20-
```
20+
```c++
2121
// If you want to use C...
2222
char *mystr = "I like C";
2323

2424
RingBuf *buf = RingBuf_new(sizeof(char*), 100);
2525
buf->add(buf, &mystr);
2626
```
2727
28-
```
28+
```c++
2929
// If you want to use the C++ wrapper
3030
char *mystr = "C++ has pretty object.method() syntax";
3131
@@ -64,7 +64,7 @@ Feel free to improve this library. Fork it, make your changes, then submit a pul
6464

6565
### Constructor
6666

67-
```
67+
```c++
6868
RingBuf *RingBuf_new(int size, int len);
6969
```
7070
@@ -73,7 +73,7 @@ This would be the equivalent of `new RingBuf(int size, int len)` in C++.
7373
7474
### Deconstructor
7575
76-
```
76+
```c++
7777
int RingBuf_delete(RingBuf *self);
7878
```
7979

@@ -84,38 +84,38 @@ Deletes the RingBuf, and frees up all the memory associated with it.
8484

8585
### add()
8686

87-
```
87+
```c++
8888
int add(RingBuf *self, void *object);
8989
```
9090
9191
Append an element to the buffer, where object is a pointer to object you wish to append. Returns -1 on a full buffer. On success, returns the position (index) in the buffer where the element was added.
9292
9393
### peek()
9494
95-
```
95+
```c++
9696
void *peek(RingBuf *self, unsigned int num);
9797
```
9898

9999
Peek at the num'th element in the buffer. Returns a void pointer to the location of the num'th element. If num is out of bounds or the num'th element is empty, a NULL pointer is returned. Cast the result of this call into a pointer of whatever type you are storing in the buffer. Note that this gives you direct memory access to the location of the num'th element in the buffer, allowing you to directly edit elements in the buffer. Note that while all of RingBuf's public methods are thread safe (including this one), directly using the pointer returned from this method is not thread safe. If there is a possibility an interrupt could fire and remove/modify the item pointed to by the returned pointer, disable interrupts first with `noInterrupts()`, do whatever you need to do with the pointer, then you can reenable interrupts by calling `interrupts()`.
100100

101101
### pull()
102102

103-
```
103+
```c++
104104
void *pull(RingBuf *self, void *object);
105105
```
106106
107107
Pull the first element out of the buffer. The first element is copied into the location pointed to by object. Returns a NULL pointer if the buffer is empty, otherwise returns object.
108108
109109
110110
### numElements()
111-
```
111+
```c++
112112
unsigned int numElements(RingBuf *self);
113113
```
114114

115115
Returns number of elements in buffer.
116116

117117
### isFull()
118-
```
118+
```c++
119119
bool isFull(RingBuf *self);
120120
```
121121
@@ -124,7 +124,7 @@ Returns true if buffer is full, otherwise false.
124124
125125
### isEmpty()
126126
127-
```
127+
```c++
128128
bool isEmpty(RingBuf *self);
129129
```
130130

0 commit comments

Comments
 (0)