#[cfg(not(any(feature = "plugin-api-v0", feature = "plugin-api-v1")))]
use crate::sys::{GArray, GByteArray};
use std::ffi::c_void;
#[cfg(not(windows))]
unsafe extern "C" {
pub(crate) fn g_free(mem: *mut c_void);
}
#[cfg(all(
not(windows),
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
unsafe extern "C" {
pub(crate) fn g_byte_array_new() -> *mut GByteArray;
pub(crate) fn g_byte_array_free(array: *mut GByteArray, free_segment: bool) -> *mut u8;
pub(crate) fn g_array_free(array: *mut GArray, free_segment: bool) -> *mut u8;
}
#[cfg(windows)]
lazy_static::lazy_static! {
static ref G_FREE : libloading::os::windows::Symbol<unsafe extern "C" fn(*mut c_void)> = {
let lib =
libloading::os::windows::Library::open_already_loaded("libglib-2.0-0.dll")
.expect("libglib-2.0-0.dll should already be loaded");
unsafe{lib.get(b"g_free").expect("find g_free")}
};
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
lazy_static::lazy_static! {
static ref G_BYTE_ARRAY_NEW: libloading::os::windows::Symbol<unsafe extern "C" fn() -> *mut GByteArray> = {
let lib =
libloading::os::windows::Library::open_already_loaded("libglib-2.0-0.dll")
.expect("libglib-2.0-0.dll should already be loaded");
unsafe{lib.get(b"g_byte_array_new").expect("find g_byte_array_new")}
};
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
lazy_static::lazy_static! {
static ref G_BYTE_ARRAY_FREE: libloading::os::windows::Symbol<unsafe extern "C" fn(*mut c_void, bool) -> *mut u8> = {
let lib =
libloading::os::windows::Library::open_already_loaded("libglib-2.0-0.dll")
.expect("libglib-2.0-0.dll should already be loaded");
unsafe{lib.get(b"g_byte_array_free").expect("find g_byte_array_free")}
};
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
lazy_static::lazy_static! {
static ref G_ARRAY_FREE: libloading::os::windows::Symbol<unsafe extern "C" fn(*mut c_void, bool) -> *mut u8> = {
let lib =
libloading::os::windows::Library::open_already_loaded("libglib-2.0-0.dll")
.expect("libglib-2.0-0.dll should already be loaded");
unsafe{lib.get(b"g_array_free").expect("find g_array_free")}
};
}
#[cfg(windows)]
pub(crate) unsafe fn g_free(mem: *mut c_void) {
unsafe { G_FREE(mem) }
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
pub(crate) unsafe fn g_byte_array_new() -> *mut GByteArray {
unsafe { G_BYTE_ARRAY_NEW() }
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
pub(crate) unsafe fn g_byte_array_free(array: *mut GByteArray, free_segment: bool) -> *mut u8 {
unsafe { G_BYTE_ARRAY_FREE(array as *mut c_void, free_segment) }
}
#[cfg(all(
windows,
not(any(feature = "plugin-api-v0", feature = "plugin-api-v1"))
))]
pub(crate) unsafe fn g_array_free(array: *mut GArray, free_segment: bool) -> *mut u8 {
unsafe { G_ARRAY_FREE(array as *mut c_void, free_segment) }
}