Convert the rest of functions to unsafe

This commit is contained in:
Dzmitry Malyshau 2020-08-22 00:16:16 -04:00 committed by Dzmitry Malyshau
parent 8ccdddda2e
commit bb40160a6a
2 changed files with 642 additions and 892 deletions

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ use std::mem;
const ICD_VERSION: u32 = 5; const ICD_VERSION: u32 = 5;
#[no_mangle] #[no_mangle]
pub extern "C" fn vk_icdGetInstanceProcAddr( pub unsafe extern "C" fn vk_icdGetInstanceProcAddr(
instance: VkInstance, instance: VkInstance,
pName: *const ::std::os::raw::c_char, pName: *const ::std::os::raw::c_char,
) -> PFN_vkVoidFunction { ) -> PFN_vkVoidFunction {
@ -16,10 +16,10 @@ pub extern "C" fn vk_icdGetInstanceProcAddr(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vk_icdNegotiateLoaderICDInterfaceVersion( pub unsafe extern "C" fn vk_icdNegotiateLoaderICDInterfaceVersion(
pSupportedVersion: *mut ::std::os::raw::c_uint, pSupportedVersion: *mut ::std::os::raw::c_uint,
) -> VkResult { ) -> VkResult {
let supported_version = unsafe { &mut *pSupportedVersion }; let supported_version = &mut *pSupportedVersion;
if *supported_version > ICD_VERSION { if *supported_version > ICD_VERSION {
*supported_version = ICD_VERSION; *supported_version = ICD_VERSION;
} }
@ -28,11 +28,11 @@ pub extern "C" fn vk_icdNegotiateLoaderICDInterfaceVersion(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vk_icdGetPhysicalDeviceProcAddr( pub unsafe extern "C" fn vk_icdGetPhysicalDeviceProcAddr(
_instance: VkInstance, _instance: VkInstance,
pName: *const ::std::os::raw::c_char, pName: *const ::std::os::raw::c_char,
) -> PFN_vkVoidFunction { ) -> PFN_vkVoidFunction {
let name = unsafe { CStr::from_ptr(pName) }; let name = CStr::from_ptr(pName);
let name = match name.to_str() { let name = match name.to_str() {
Ok(name) => name, Ok(name) => name,
Err(_) => return None, Err(_) => return None,