From: Jonathan Nieder Date: Mon, 16 Jun 2014 20:16:44 GMT Subject: Re: [PATCH 1/3] add strnncmp() function Message-ID: <20140616201644.GN8557@google.com> In-Reply-To: <58e0ac866bdeb8cc6e06cf553a459af351ccfd1b.1402945507.git.jmmahler@gmail.com> Jeremiah Mahler wrote: > Add a strnncmp() function which behaves like strncmp() except it uses > the length of both strings instead of just one. The above description isn't very clear to me. Problems: - strncmp compares prefixes of \0-terminated strings. This function compares two binary buffers which can contain \0 - strncmp is a comparison function and can even be used with functions like qsort (for operations like "sort on the first two characters"). This function returns 0 or nonzero. Would something like /* true if buffers have the same length and are byte-for-byte identical */ int bufeq(const char *, int, const char *, int); (or buf_equal, array_equal etc) make sense?