sets the read pointer to the beginning of the buffer
| 91 | |
| 92 | // sets the read pointer to the beginning of the buffer |
| 93 | void CircularBuffer_ResetReader |
| 94 | ( |
| 95 | CircularBuffer cb // circular buffer |
| 96 | ) { |
| 97 | // compensate for circularity |
| 98 | uint64_t write = cb->write; |
| 99 | uint write_idx = write / cb->item_size; |
| 100 | int sub = write_idx - cb->item_count; |
| 101 | if(sub >= 0) { |
| 102 | cb->read = cb->data + (sub * cb->item_size); |
| 103 | } else { |
| 104 | cb->read = cb->end_marker + (sub * cb->item_size); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // adds an item to buffer |
| 109 | // returns 1 on success, 0 otherwise |
no outgoing calls
no test coverage detected