snprintf (d, size, "%s", s)
->
memccpy (d, s, '\0', size - 1),
d[size - 1] = 0
memccpy is much faster than snprintf my microbenchmark
time ./snprintf.out 1000000
real 0m0,057s
user 0m0,057s
sys 0m0,000s
time ./memccpy.out 1000000
real 0m0,021s
user 0m0,021s
sys 0m0,000s
Where did we ask TLI about the existence of memccpy?