xref: /freebsd/contrib/libdiff/test/test004.left.txt (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
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