From 4466d15442f2ce36813e1e15779e9fb8aaebcdf3 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Fri, 26 Jul 2024 10:59:42 -0700 Subject: [PATCH] myers/middle_snake: correct safety doc 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. --- src/myers/middle_snake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/myers/middle_snake.rs b/src/myers/middle_snake.rs index a23dd15..9a33554 100644 --- a/src/myers/middle_snake.rs +++ b/src/myers/middle_snake.rs @@ -16,7 +16,7 @@ pub struct MiddleSnakeSearch { impl MiddleSnakeSearch { /// # 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, file1: &FileSlice, file2: &FileSlice) -> Self { let dmin = -(file2.len() as i32); let dmax = file1.len() as i32;