6 ms·
Yes, the ceremony to set up a ring buffer was confusing. But isn't getchar() at least doing the same as before? If the ring buffer is empty, ring_buffer_get()
by unwind 11y ago
Yes, the ceremony to set up a ring buffer was confusing.
But isn't getchar() at least doing the same as before?
If the ring buffer is empty, ring_buffer_get() won't write to its data argument, and since getchar() passes in -1, that's what it's going to be returning if the buffer was empty. Just like it says it did before using a ring buffer.