Actually this lead to ugly code. 0 length is not going to be returning null as by symmetry to strndup, we would only return NULL if the string is NULL. Otherwise we should return a valid empty string. So I don't think this is a good idea to implement. Leaning on strndup simplify the code and guarantee behavior to properly match user expectation.