1
0
mirror of https://github.com/medigor/example-native-api-rs.git synced 2025-07-05 00:58:53 +02:00

исправил unsafe в некоторых местах

This commit is contained in:
medigor
2022-12-11 23:49:46 +03:00
parent 6c591c08f8
commit 03e499d28b
2 changed files with 5 additions and 8 deletions

View File

@ -342,7 +342,7 @@ unsafe extern "system" fn register_extension_as<T: Addin>(
return false; return false;
}; };
data.copy_from_slice(extension_name); data.copy_from_slice(extension_name);
unsafe { *name = data.as_mut_ptr() }; *name = data.as_mut_ptr();
true true
} }
@ -704,11 +704,10 @@ pub struct Connection {
unsafe fn get_str<'a>(s: *const u16) -> &'a [u16] { unsafe fn get_str<'a>(s: *const u16) -> &'a [u16] {
unsafe fn strlen(s: *const u16) -> usize { unsafe fn strlen(s: *const u16) -> usize {
let mut i = 0; let mut i = 0;
while unsafe { *s.add(i) } != 0 { while *s.add(i) != 0 {
i += 1; i += 1;
} }
i += 1; i + 1
i
} }
let len = strlen(s); let len = strlen(s);

View File

@ -46,10 +46,8 @@ pub extern "C" fn GetClassNames() -> *const u16 {
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[no_mangle] #[no_mangle]
pub extern "C" fn SetPlatformCapabilities(capabilities: c_int) -> c_int { pub unsafe extern "C" fn SetPlatformCapabilities(capabilities: c_int) -> c_int {
unsafe { PLATFORM_CAPABILITIES.store(capabilities, Ordering::Relaxed);
PLATFORM_CAPABILITIES.store(capabilities, Ordering::Relaxed);
}
3 3
} }