Hi, On Sun, 7 Oct 2007, Timo Hirvonen wrote: > Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote: > > > On Sun, 7 Oct 2007, Pierre Habouzit wrote: > > > > > On Sun, Oct 07, 2007 at 02:24:25PM +0000, Timo Hirvonen wrote: > > > > > > > strbuf->buf is always non-NULL and NUL-terminated so you could just do > > > > > > > > static inline int strbuf_cmp(const struct strbuf *a, const struct strbuf *b) > > > > { > > > > int len = a->len < b->len ? a->len : b->len; > > > > return memcmp(a->buf, b->buf, len + 1); > > > > } > > > > > > doesn't work, because a buffer can have (in some very specific cases) > > > an embeded NUL. > > > > But it should work. The function memcmp() could not care less if there is > > a NUL or not, it just compares until it finds a difference. > > Almost. If a is "hello\0world" and b is "hello" then it would compare 6 > characters from both and think the strings are equal. Good point. Ciao, Dscho - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html