4 ms·
So this safe function cannot be used with dynamically allocated buffers without casting them? That means it takes away the benefit of not passing in the size ex
by IgorPartola 14y ago
So this safe function cannot be used with dynamically allocated buffers without casting them? That means it takes away the benefit of not passing in the size explicitly. It also does not deal with wide chars.
I think storing sizes explicitly is the better solution. If what you are dealing with are actually character strings, then you might store the byte size along with the char count.
If you are only dealing with ASCII (are you sure?), you could use memcpy and avoid the strncpy zero fill behavior.