rusticl: Use C-string literals for DiskCache::new
Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31510>
This commit is contained in:
@@ -60,7 +60,7 @@ fn get_disk_cache() -> &'static Option<DiskCache> {
|
||||
];
|
||||
unsafe {
|
||||
DISK_CACHE_ONCE.call_once(|| {
|
||||
DISK_CACHE = DiskCache::new("rusticl", &func_ptrs, 0);
|
||||
DISK_CACHE = DiskCache::new(c"rusticl", &func_ptrs, 0);
|
||||
});
|
||||
&*addr_of!(DISK_CACHE)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use libc_rust_gen::free;
|
||||
use mesa_rust_gen::*;
|
||||
|
||||
use std::ffi::{c_void, CString};
|
||||
use std::ffi::{c_void, CStr};
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
@@ -75,8 +75,7 @@ impl DiskCacheBorrowed {
|
||||
}
|
||||
|
||||
impl DiskCache {
|
||||
pub fn new(name: &str, func_ptrs: &[*mut c_void], flags: u64) -> Option<Self> {
|
||||
let c_name = CString::new(name).unwrap();
|
||||
pub fn new(name: &CStr, func_ptrs: &[*mut c_void], flags: u64) -> Option<Self> {
|
||||
let mut sha_ctx = SHA1_CTX::default();
|
||||
let mut sha = [0; SHA1_DIGEST_LENGTH as usize];
|
||||
let mut cache_id = [0; SHA1_DIGEST_STRING_LENGTH as usize];
|
||||
@@ -91,7 +90,7 @@ impl DiskCache {
|
||||
}
|
||||
SHA1Final(&mut sha, &mut sha_ctx);
|
||||
mesa_bytes_to_hex(cache_id.as_mut_ptr(), sha.as_ptr(), sha.len() as u32);
|
||||
disk_cache_create(c_name.as_ptr(), cache_id.as_ptr(), flags)
|
||||
disk_cache_create(name.as_ptr(), cache_id.as_ptr(), flags)
|
||||
};
|
||||
|
||||
DiskCacheBorrowed::from_ptr(cache).map(|c| Self { inner: c })
|
||||
|
||||
Reference in New Issue
Block a user