FreeTDM: Add ftdm_clamp_safe()
"Safer" version of ftdm_clamp(), that swaps min/max parameters if vmin happens to be larger than vmax, making sure the output will always satisfy vmin <= x <= vmax. Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
parent
90691b36c4
commit
1d605ef47b
|
@ -87,6 +87,10 @@ typedef uint64_t ftdm_time_t;
|
||||||
/*! \brief Get value that is in range [vmin,vmax] */
|
/*! \brief Get value that is in range [vmin,vmax] */
|
||||||
#define ftdm_clamp(val,vmin,vmax) ftdm_max(vmin,ftdm_min(val,vmax))
|
#define ftdm_clamp(val,vmin,vmax) ftdm_max(vmin,ftdm_min(val,vmax))
|
||||||
|
|
||||||
|
/*!< \brief Safer version of ftdm_clamp(), that swaps vmin/vmax parameters if vmin > vmax */
|
||||||
|
#define ftdm_clamp_safe(val,vmin,vmax) \
|
||||||
|
ftdm_clamp(val, ftdm_min(vmin,vmax), ftdm_max(vmin,vmax))
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get offset of member in structure
|
* \brief Get offset of member in structure
|
||||||
* \param[in] type Type of struct
|
* \param[in] type Type of struct
|
||||||
|
|
Loading…
Reference in New Issue