Alex Riesen <raa.lkml@xxxxxxxxx> writes: > int strbuf_cmp2(struct strbuf *a, struct strbuf *b) > { > int len = a->len < b->len ? a->len: b->len; > int cmp = memcmp(a->buf, b->buf, len); > if (cmp) > return cmp; > return a->len < b->len ? -1: a->len != b->len; > } BTW, why are you making such effort to return only -1, 0, or 1 in the last line? memcmp/strcmp make no such guarantee; e.g. glibc says: The `strcmp' function compares the string S1 against S2, returning a value that has the same sign as the difference between the first differing pair of characters (interpreted as `unsigned char' objects, then promoted to `int'). If the two strings are equal, `strcmp' returns `0'. A consequence of the ordering used by `strcmp' is that if S1 is an initial substring of S2, then S1 is considered to be "less than" S2. So I think the last line can just be: return a->len - b->len; -miles -- Suburbia: where they tear out the trees and then name streets after them. - 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