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