* @brief Get the number of blocks along a single axis. * * This function is implemented so that intermediate values will not overflow, * which may occur when input values are not trusted. Implementation is * obviously slower than one that does not do this, so don't use for values * we know cannot overflow. * * @param dim_axis The axis dimension, in pixels. * @param dim_block The block
| 514 | * @return The number of blocks needed in this dimension. |
| 515 | */ |
| 516 | static inline size_t get_block_count_safe( |
| 517 | size_t dim_axis, |
| 518 | size_t dim_block |
| 519 | ) { |
| 520 | // Compute number of whole blocks |
| 521 | size_t blocks = dim_axis / dim_block; |
| 522 | |
| 523 | // Add in any residual partial block |
| 524 | if (dim_axis != (dim_block * blocks)) |
| 525 | { |
| 526 | blocks++; |
| 527 | } |
| 528 | |
| 529 | return blocks; |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * @brief Initialize the seed structure for a random number generator. |
no outgoing calls
no test coverage detected