andrewrk / andrewrk/libsoundio
ring_buffer asserts on overflow
- Langage dominant
- C
- Étoiles
- 2.1k
- Forks
- 254
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
```
int soundio_ring_buffer_fill_count(struct SoundIoRingBuffer *rb) {
// Whichever offset we load first might have a smaller value. So we load
// the read_offset first.
long read_offset = SOUNDIO_ATOMIC_LOAD(rb->read_offset);
long write_offset = SOUNDIO_ATOMIC_LOAD(rb->write_offset);
int count = write_offset - read_offset;
assert(count >= 0);
assert(count <= rb->capacity);
return count;
}
```
I guess that is by design but it is definitely not the expected behaviour. I would either expect the read pointer to follow the write pointer when it was full. This would require the ring buffer to know its element size which is probably a good idea anyway.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.