xref: /freebsd/contrib/libdiff/test/test104.right-P.txt (revision 725a9f47324d42037db93c27ceb40d4956872f3e)
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