#define _GNU_SOURCE #include #include #include #include #include bool cmp_find(const map_t *pIN needle, const map_t *pIN haystack, usize *pOUT pos) { u8* start; u8* substr = memmem(start = haystack->origin, haystack->len, needle->origin, needle->len); if(!substr) return false; debug_assert(substr > start); *pos = (usize) (substr - start); return true; } int cmp_find_many(usize nhaystacks; const map_t *pIN needle, usize sizes[pOUT nhaystacks], usize nhaystacks, ...) { va_list v_haystacks; va_start(v_haystacks, nhaystacks); const map_t* pINOUT haystack; for(usize i=0;iorigin) FATAL("haystack %lu was null or its origin was null", i); if(!cmp_find(needle, haystack, size)) return (int)i; } va_end(v_haystacks); return -1; }