xref: /freebsd/contrib/libdiff/test/test004.right.txt (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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