33use libc:: { c_void, size_t} ;
44
55extern "C" {
6- pub fn mi_zalloc ( size : size_t ) -> * const c_void ;
7- pub fn mi_malloc ( size : size_t ) -> * const c_void ;
8- pub fn mi_realloc ( p : * const c_void , size : size_t ) -> * const c_void ;
9- pub fn mi_zalloc_aligned ( size : size_t , alignment : size_t ) -> * const c_void ;
10- pub fn mi_malloc_aligned ( size : size_t , alignment : size_t ) -> * const c_void ;
11- pub fn mi_realloc_aligned ( p : * const c_void , size : size_t , alignment : size_t ) -> * const c_void ;
12- pub fn mi_free ( p : * const c_void ) -> c_void ;
6+ pub fn mi_zalloc ( size : size_t ) -> * const c_void ;
7+ pub fn mi_malloc ( size : size_t ) -> * const c_void ;
8+ pub fn mi_realloc ( p : * const c_void , size : size_t ) -> * const c_void ;
9+ pub fn mi_zalloc_aligned ( size : size_t , alignment : size_t ) -> * const c_void ;
10+ pub fn mi_malloc_aligned ( size : size_t , alignment : size_t ) -> * const c_void ;
11+ pub fn mi_realloc_aligned ( p : * const c_void , size : size_t , alignment : size_t ) -> * const c_void ;
12+ pub fn mi_free ( p : * const c_void ) -> c_void ;
1313}
1414
1515#[ cfg( test) ]
1616mod tests {
17- use super :: * ;
17+ use super :: * ;
1818
19- #[ test]
20- fn it_frees_memory_malloc ( ) {
21- let ptr = unsafe { mi_malloc_aligned ( 8 , 8 ) } as * mut u8 ;
22- unsafe { mi_free ( ptr as * const c_void ) } ;
23- }
19+ #[ test]
20+ fn it_frees_memory_malloc ( ) {
21+ let ptr = unsafe { mi_malloc_aligned ( 8 , 8 ) } as * mut u8 ;
22+ unsafe { mi_free ( ptr as * const c_void ) } ;
23+ }
2424
25- #[ test]
26- fn it_frees_memory_zalloc ( ) {
27- let ptr = unsafe { mi_zalloc_aligned ( 8 , 8 ) } as * mut u8 ;
28- unsafe { mi_free ( ptr as * const c_void ) } ;
29- }
25+ #[ test]
26+ fn it_frees_memory_zalloc ( ) {
27+ let ptr = unsafe { mi_zalloc_aligned ( 8 , 8 ) } as * mut u8 ;
28+ unsafe { mi_free ( ptr as * const c_void ) } ;
29+ }
3030
31- #[ test]
32- fn it_frees_memory_realloc ( ) {
33- let ptr = unsafe { mi_malloc_aligned ( 8 , 8 ) } as * mut u8 ;
34- let ptr = unsafe { mi_realloc_aligned ( ptr as * const c_void , 8 , 8 ) } as * mut u8 ;
35- unsafe { mi_free ( ptr as * const c_void ) } ;
36- }
37- }
31+ #[ test]
32+ fn it_frees_memory_realloc ( ) {
33+ let ptr = unsafe { mi_malloc_aligned ( 8 , 8 ) } as * mut u8 ;
34+ let ptr = unsafe { mi_realloc_aligned ( ptr as * const c_void , 8 , 8 ) } as * mut u8 ;
35+ unsafe { mi_free ( ptr as * const c_void ) } ;
36+ }
37+ }
0 commit comments