blob: e54f9847ec2c636167200872d917f5f2e76e4d6d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <string.h>
#include "mbstring.h"
/* Technically you can’t pass nullptr to memcmp(), so we check for x.len and
y.len both being 0 */
int
u8cmp(struct u8view x, struct u8view y)
{
if (x.len != y.len)
return x.len > y.len ? +1 : -1;
return x.len == 0 && y.len == 0 ? 0 : memcmp(x.p, y.p, x.len);
}
|