Amusingly, I just looked up some proprietary code for a ring buffer implementation I did back in 2009. It has race condition locks so it's more complex than your version #1. But as it turns out, I did implement it type-generic with
void
pointers just like your code and then put it through MISRA C compliance. So much for arguing against generic programming in safety-related software! :) That code was tested very extensive with stress tests & dynamic analysis etc and it now runs inside lots of heavy machinery since 15 years back. But I wouldn't have written code like that today.