Skip to content

Commit

Permalink
myers/middle_snake: correct safety doc (#11)
Browse files Browse the repository at this point in the history
In the documentation for MiddleSnakeSearch::new, the safety constraints
described on the `data` pointer do not exactly match how the class
uses it. It is stored as the `kvec` field, and looking at the
`write_xpos_at_diagonal`, `x_pos_at_diagonal`, and `pos_at_diagonal`
functions (a search of `kvec` in the source code revealing that all
access to `kvec` go through one of these functions):

- writes could happen, not only reads
- the range of access is as described in the bounds_check function

Therefore, update the documentation accordingly.
  • Loading branch information
jonathantanmy authored Jul 26, 2024
1 parent 17bcaa8 commit 6fc0dc1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/myers/middle_snake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct MiddleSnakeSearch<const BACK: bool> {

impl<const BACK: bool> MiddleSnakeSearch<BACK> {
/// # Safety
/// `data` must be valid for reads between `-file1.len()` and `file2.len()`
/// `data` must be valid for reads and writes between `-file2.len() - 1` and `file1.len() + 1`
pub unsafe fn new(data: NonNull<i32>, file1: &FileSlice, file2: &FileSlice) -> Self {
let dmin = -(file2.len() as i32);
let dmax = file1.len() as i32;
Expand Down

0 comments on commit 6fc0dc1

Please sign in to comment.