xref: /freebsd/contrib/libdiff/test/test004.right.txt (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1int Chunk_bounds_check(Chunk *chunk, size_t start, size_t n)
2{
3    if (chunk == NULL) return 0;
4
5    return start <= chunk->length && n <= chunk->length - start;
6}
7
8void Chunk_copy(Chunk *src, size_t src_start, Chunk *dst, size_t dst_start, size_t n)
9{
10    if (!Chunk_bounds_check(src, src_start, n)) return;
11    if (!Chunk_bounds_check(dst, dst_start, n)) return;
12
13    memcpy(dst->data + dst_start, src->data + src_start, n);
14}
15