sp_brightness_grid_load ignore out of range
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Rust / build (pull_request) Failing after 30s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Rust / build (pull_request) Failing after 30s
				
			This commit is contained in:
		
							parent
							
								
									2e468fb47a
								
							
						
					
					
						commit
						a418e4f0c3
					
				
					 2 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
					@ -24,7 +24,7 @@ sort_by = "Name"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[parse]
 | 
					[parse]
 | 
				
			||||||
parse_deps = true
 | 
					parse_deps = true
 | 
				
			||||||
include = ["servicepoint"]
 | 
					include = ["servicepoint", "std"]
 | 
				
			||||||
extra_bindings = ["servicepoint"]
 | 
					extra_bindings = ["servicepoint"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[parse.expand]
 | 
					[parse.expand]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,8 @@ pub unsafe extern "C" fn sp_brightness_grid_new(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Loads a [BrightnessGrid] with the specified dimensions from the provided data.
 | 
					/// Loads a [BrightnessGrid] with the specified dimensions from the provided data.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
 | 
					/// Any out of range values will be set to [Brightness::MAX] or [Brightness::MIN].
 | 
				
			||||||
 | 
					///
 | 
				
			||||||
/// returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
					/// returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
				
			||||||
#[no_mangle]
 | 
					#[no_mangle]
 | 
				
			||||||
pub unsafe extern "C" fn sp_brightness_grid_load(
 | 
					pub unsafe extern "C" fn sp_brightness_grid_load(
 | 
				
			||||||
| 
						 | 
					@ -38,14 +40,12 @@ pub unsafe extern "C" fn sp_brightness_grid_load(
 | 
				
			||||||
    data: ByteSlice,
 | 
					    data: ByteSlice,
 | 
				
			||||||
) -> *mut BrightnessGrid {
 | 
					) -> *mut BrightnessGrid {
 | 
				
			||||||
    let data = unsafe { data.as_slice() };
 | 
					    let data = unsafe { data.as_slice() };
 | 
				
			||||||
    let grid = match ByteGrid::load(width, height, data) {
 | 
					
 | 
				
			||||||
        None => return std::ptr::null_mut(),
 | 
					    match ByteGrid::load(width, height, data)
 | 
				
			||||||
        Some(grid) => grid,
 | 
					        .map(move |grid| grid.map(Brightness::saturating_from))
 | 
				
			||||||
    };
 | 
					    {
 | 
				
			||||||
    if let Ok(grid) = BrightnessGrid::try_from(grid) {
 | 
					        None => std::ptr::null_mut(),
 | 
				
			||||||
        heap_move(grid)
 | 
					        Some(grid) => heap_move(grid),
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        std::ptr::null_mut()
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue