File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ extern "C" {
10
10
pub fn mi_malloc_aligned ( size : usize , alignment : usize ) -> * const c_void ;
11
11
pub fn mi_realloc_aligned ( p : * const c_void , size : usize , alignment : usize ) -> * const c_void ;
12
12
pub fn mi_free ( p : * const c_void ) -> c_void ;
13
+ pub fn mi_usable_size ( p : * mut c_void ) -> usize ;
13
14
}
14
15
15
16
#[ cfg( test) ]
@@ -34,4 +35,14 @@ mod tests {
34
35
let ptr = unsafe { mi_realloc_aligned ( ptr as * const c_void , 8 , 8 ) } as * mut u8 ;
35
36
unsafe { mi_free ( ptr as * const c_void ) } ;
36
37
}
38
+
39
+ #[ test]
40
+ fn it_calculates_usable_size ( ) {
41
+ let ptr = unsafe { mi_malloc ( 32 ) } as * mut u8 ;
42
+ let usable_size = unsafe { mi_usable_size ( ptr as * mut c_void ) } ;
43
+ assert ! (
44
+ usable_size >= 32 ,
45
+ "usable_size should at least equal to the allocated size"
46
+ ) ;
47
+ }
37
48
}
You can’t perform that action at this time.
0 commit comments