eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 3f1313e801ffd4db18e7fec5c3dbbf0984ec16b3
parent 6cd2b9c11558a831389bd204cec470e345b0bef4
Author: Daniel Barlow <dan@telent.net>
Date:   Thu, 25 Dec 2025 15:15:25 +0000

encoded label ends with 0 byte

Diffstat:
Mecu-portable/src/lib.rs | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ecu-portable/src/lib.rs b/ecu-portable/src/lib.rs @@ -11,7 +11,8 @@ pub fn ptr_data<'b>(labels : &[&str], buf : &'b mut[u8]) -> &'b mut [u8] { } offset = offset + l.len() + 1; } - &mut buf[..offset] + buf[offset] = 0; + &mut buf[..(offset+1)] } @@ -24,18 +25,20 @@ mod tests { fn test_ptr_data() { let mut buf : [u8; 32] = [0; 32]; assert_eq!(ptr_data(&["hello"], &mut buf), - [5, 104, 101, 108, 108, 111]); + [5, 104, 101, 108, 108, 111, 0 ]); assert_eq!(ptr_data(&[], &mut buf), - []); + [0]); assert_eq!(ptr_data(&["hello", "world"], &mut buf), [5, 104, 101, 108, 108, 111, - 5, 119, 111, 114, 108, 100]); + 5, 119, 111, 114, 108, 100, + 0]); assert_eq!(ptr_data(&["hello", "cool", "world"], &mut buf), [5, 104, 101, 108, 108, 111, 4, 99, 111, 111, 108, - 5, 119, 111, 114, 108, 100]); + 5, 119, 111, 114, 108, 100, + 0]); } }