/* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ #include "include.h" int array_compare(const arr_t* s0, const arr_t* s1) { void *e, *p0, *p1; int cmp; if (s0 == s1 || (!s0->size && !s0->size)) return 0; if (s0->type != s1->type) return (s0->type < s1->type) ? -1 : 1; if (s0->size != s1->size) return (s0->size < s1->size) ? -1 : 1; p0 = s0->mem; p1 = s1->mem; e = array_end(s0); do { cmp = vtype_compare_eq(p0, p1, s0->type); if (cmp == 0) { p0 += vtype_size(s0->type); p1 += vtype_size(s0->type); } else return cmp; } while (p0 < e); return 0; }