2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
2022-09-26 10:38:14 +00:00
|
|
|
// only-windows
|
2019-07-26 21:54:25 +00:00
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
2015-09-17 09:03:27 +00:00
|
|
|
pub type HANDLE = usize;
|
2013-03-07 03:09:17 +00:00
|
|
|
pub type DWORD = u32;
|
|
|
|
pub type SIZE_T = u32;
|
2015-03-26 00:06:52 +00:00
|
|
|
pub type LPVOID = usize;
|
2013-03-07 03:09:17 +00:00
|
|
|
pub type BOOL = u8;
|
2011-11-09 23:27:11 +00:00
|
|
|
|
2013-03-05 22:42:58 +00:00
|
|
|
mod kernel32 {
|
2022-09-26 10:38:14 +00:00
|
|
|
use super::{BOOL, DWORD, HANDLE, LPVOID, SIZE_T};
|
2013-03-07 03:09:17 +00:00
|
|
|
|
2013-11-10 22:57:53 +00:00
|
|
|
extern "system" {
|
2013-03-05 22:42:58 +00:00
|
|
|
pub fn GetProcessHeap() -> HANDLE;
|
2022-09-26 10:38:14 +00:00
|
|
|
pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
|
2013-03-05 22:42:58 +00:00
|
|
|
pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
|
|
|
|
}
|
2011-11-09 23:27:11 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-01-26 00:58:04 +00:00
|
|
|
let heap = unsafe { kernel32::GetProcessHeap() };
|
2015-03-03 08:42:26 +00:00
|
|
|
let mem = unsafe { kernel32::HeapAlloc(heap, 0, 100) };
|
|
|
|
assert!(mem != 0);
|
|
|
|
let res = unsafe { kernel32::HeapFree(heap, 0, mem) };
|
|
|
|
assert!(res != 0);
|
2011-11-09 23:27:11 +00:00
|
|
|
}
|