strbuf: use CMP() macro

strbuf_child_entry.c is uint8_t, so using CMP() is safer.

This also adds missing assertions.
This commit is contained in:
Yu Watanabe 2024-06-13 00:17:20 +09:00
parent 1b3449d8c1
commit 7b12b86450

View file

@ -74,9 +74,11 @@ struct strbuf* strbuf_free(struct strbuf *str) {
return mfree(str);
}
static int strbuf_children_cmp(const struct strbuf_child_entry *n1,
const struct strbuf_child_entry *n2) {
return n1->c - n2->c;
static int strbuf_children_cmp(const struct strbuf_child_entry *n1, const struct strbuf_child_entry *n2) {
assert(n1);
assert(n2);
return CMP(n1->c, n2->c);
}
static void bubbleinsert(struct strbuf_node *node,