@@ -40,11 +40,12 @@ pub struct BufferAllocatorSettings {
4040impl BufferAllocatorSettings {
4141 /// Initializes the buffer allocator with default settings.
4242 pub fn new ( ) -> Self {
43+ let sys_info = get_sys_info ( ) ;
4344 Self {
4445 min_address : 0 ,
45- max_address : get_sys_info ( ) . max_address ,
46+ max_address : sys_info . max_address ,
4647 size : 4096 ,
47- target_process_id : get_sys_info ( ) . this_process_id ,
48+ target_process_id : sys_info . this_process_id ,
4849 retry_count : 8 ,
4950 brute_force : true ,
5051 }
@@ -73,15 +74,15 @@ impl BufferAllocatorSettings {
7374 /// Sanitizes the input values.
7475 pub fn sanitize ( & mut self ) {
7576 // On Windows, VirtualAlloc treats 0 as 'any address', we might aswell avoid this out the gate.
76- if cfg ! ( windows) && ( self . min_address < get_sys_info ( ) . allocation_granularity as usize ) {
77- self . min_address = get_sys_info ( ) . allocation_granularity as usize ;
77+ let sys_info = get_sys_info ( ) ;
78+ if cfg ! ( windows) && ( self . min_address < sys_info. allocation_granularity as usize ) {
79+ self . min_address = sys_info. allocation_granularity as usize ;
7880 }
7981
8082 self . size = max ( self . size , 1 ) ;
81- self . size = mathematics:: round_up (
82- self . size as usize ,
83- get_sys_info ( ) . allocation_granularity as usize ,
84- ) as u32 ;
83+ self . size =
84+ mathematics:: round_up ( self . size as usize , sys_info. allocation_granularity as usize )
85+ as u32 ;
8586 }
8687}
8788
0 commit comments