1
0
mirror of https://github.com/medigor/example-native-api-rs.git synced 2025-07-03 00:58:13 +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;
};
data.copy_from_slice(extension_name);
unsafe { *name = data.as_mut_ptr() };
*name = data.as_mut_ptr();
true
}
@ -704,11 +704,10 @@ pub struct Connection {
unsafe fn get_str<'a>(s: *const u16) -> &'a [u16] {
unsafe fn strlen(s: *const u16) -> usize {
let mut i = 0;
while unsafe { *s.add(i) } != 0 {
while *s.add(i) != 0 {
i += 1;
}
i += 1;
i
i + 1
}
let len = strlen(s);

View File

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