Merge pull request #339 from djmitche/uuid-len-const
use TC_UUID_STRING_BYTES constant directly
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3039,7 +3039,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"taskchampion",
|
"taskchampion",
|
||||||
"uuid",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ crate-type = ["staticlib", "cdylib"]
|
|||||||
libc = "0.2.113"
|
libc = "0.2.113"
|
||||||
chrono = "^0.4.10"
|
chrono = "^0.4.10"
|
||||||
taskchampion = { path = "../taskchampion" }
|
taskchampion = { path = "../taskchampion" }
|
||||||
uuid = { version = "^0.8.2", features = ["v4"] }
|
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -87,9 +87,8 @@ pub unsafe extern "C" fn tc_uuid_to_buf(tcuuid: TCUuid, buf: *mut libc::c_char)
|
|||||||
// - content of buf will not be mutated during the lifetime of this slice (lifetime
|
// - content of buf will not be mutated during the lifetime of this slice (lifetime
|
||||||
// does not outlive this function call)
|
// does not outlive this function call)
|
||||||
// - the length of the buffer is less than isize::MAX (promised by caller)
|
// - the length of the buffer is less than isize::MAX (promised by caller)
|
||||||
let buf: &mut [u8] = unsafe {
|
let buf: &mut [u8] =
|
||||||
std::slice::from_raw_parts_mut(buf as *mut u8, ::uuid::adapter::Hyphenated::LENGTH)
|
unsafe { std::slice::from_raw_parts_mut(buf as *mut u8, TC_UUID_STRING_BYTES) };
|
||||||
};
|
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// - tcuuid is a valid TCUuid (all byte patterns are valid)
|
// - tcuuid is a valid TCUuid (all byte patterns are valid)
|
||||||
let uuid: Uuid = unsafe { TCUuid::val_from_arg(tcuuid) };
|
let uuid: Uuid = unsafe { TCUuid::val_from_arg(tcuuid) };
|
||||||
|
|||||||
Reference in New Issue
Block a user